- 
                Notifications
    
You must be signed in to change notification settings  - Fork 3.4k
 
perform filesystem R/W checks at startup #10177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -740,3 +740,18 @@ def update_recently_opened_wallets(self, wallet_path, *, remove: bool = False): | |
| recent = recent[:5] | ||
| self.config.RECENTLY_OPEN_WALLET_FILES = recent | ||
| util.trigger_callback('recently_opened_wallets_update') | ||
| 
     | 
||
| 
     | 
||
| def check_fs_permissions(config: 'SimpleConfig'): | ||
| electrum_path = config.electrum_path() | ||
| if not os.access(electrum_path, os.R_OK | os.W_OK): | ||
| raise Exception('can not read/write root folder at ' + electrum_path) | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "can not" is grammatically incorrect, please change to "Cannot". See the factored out example above.  | 
||
| for f in ['config', 'blockchain_headers', 'recent_servers']: | ||
| fpath = os.path.join(electrum_path, f) | ||
| if os.path.exists(fpath): | ||
| if not os.access(fpath, os.R_OK | os.W_OK): | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The os.access() check is repeated a few times with the exception message. def check_permissions(path: str):
    if not os.access(path, os.R_OK | os.W_OK):
        raise Exception(f'Cannot read/write {path}') | 
||
| raise Exception(f'can not read/write {f} file at ' + electrum_path) | ||
| fpath = os.path.join(electrum_path, 'wallets') | ||
| if not os.access(fpath, os.R_OK | os.W_OK): | ||
| raise Exception('can not read/write wallet folder at ' + fpath) | ||
| 
     | 
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only function below the classes, while other generic functions such as this one lives in the beginning of the file. Maybe it could be moved there to keep the file organized that way.