-
Notifications
You must be signed in to change notification settings - Fork 96
set file's trashed attribute to true instead of permanently removing it
#178
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 1 commit
d6a1181
68e1b3a
1d3fb58
ed2174d
28b9697
a07613a
2b6fc66
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 |
|---|---|---|
|
|
@@ -769,13 +769,20 @@ def remove_entry(self, normalized_entry): | |
| _logger.info("Removing entry with ID [%s].", normalized_entry.id) | ||
|
|
||
| client = self.__auth.get_client() | ||
|
|
||
| args = { | ||
|
||
| 'fileId': normalized_entry.id | ||
| } | ||
|
|
||
| delete_to_trash = gdrivefs.conf.Conf.get('delete_to_trash') | ||
|
|
||
| try: | ||
| result = client.files().trash(**args).execute() | ||
| if delete_to_trash: | ||
| _logger.debug("Moving file to trash") | ||
| result = client.files().trash(**args).execute() | ||
| else: | ||
| _logger.debug("Deleting file permanently") | ||
| result = client.files().delete(**args).execute() | ||
| except Exception as e: | ||
| if e.__class__.__name__ == 'HttpError' and \ | ||
| str(e).find('File not found') != -1: | ||
|
|
||
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.
In get() make sure to use an inequality, not is. is is only used when checking that one instance is the same as another. By contrast, creating two different objects (instances) from the same class should always return False. Note that string caching may create inconsistent results when comparing strings. Consequently, you should only use is for comparing False, True, and None.