-
Notifications
You must be signed in to change notification settings - Fork 72
fs: add acknowledge_abuse parameter #214
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
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 |
---|---|---|
|
@@ -159,14 +159,15 @@ def __init__( | |
self, | ||
path, | ||
google_auth=None, | ||
trash_only=True, | ||
client_id=None, | ||
client_secret=None, | ||
client_user_email=None, | ||
client_json=None, | ||
client_json_file_path=None, | ||
use_service_account=False, | ||
profile=None, | ||
trash_only=True, | ||
acknowledge_abuse=False, | ||
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. style/minor - move trash only nearby to this one 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. Strictly speaking, that would be breaking backwards compatibility. But we can add an 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. Introducing the guard forces changing tests, which is out of scope here. Can get back to this separately in a followup. For now moved those flags nearby, as requested. |
||
**kwargs, | ||
): | ||
"""Create an instance of GDriveFileSystem. | ||
|
@@ -175,8 +176,6 @@ def __init__( | |
:type path: str. | ||
:param google_auth: Authenticated GoogleAuth instance. | ||
:type google_auth: GoogleAuth. | ||
:param trash_only: Move files to trash instead of deleting. | ||
:type trash_only: bool. | ||
:param client_id: Client ID of the application. | ||
:type client_id: str | ||
:param client_secret: Client secret of the application. | ||
|
@@ -192,6 +191,11 @@ def __init__( | |
:type use_service_account: bool. | ||
:param profile: Profile name for caching credentials | ||
(ignored for service account). | ||
:param trash_only: Move files to trash instead of deleting. | ||
:type trash_only: bool. | ||
:param acknowledge_abuse: Acknowledging the risk and download file | ||
identified as abusive. | ||
:type acknowledge_abuse: bool | ||
:type profile: str. | ||
:raises: GDriveAuthError | ||
""" | ||
|
@@ -229,6 +233,7 @@ def __init__( | |
|
||
self.client = GoogleDrive(google_auth) | ||
self._trash_only = trash_only | ||
self._acknowledge_abuse = acknowledge_abuse | ||
|
||
def split_path(self, path): | ||
parts = path.replace("//", "/").rstrip("/").split("/", 1) | ||
|
@@ -549,7 +554,7 @@ def _gdrive_get_file(self, item_id, rpath, callback=None, block_size=None): | |
# it does not create a file on the remote | ||
gdrive_file = self.client.CreateFile(param) | ||
|
||
extra_args = {} | ||
extra_args = {"acknowledge_abuse": self._acknowledge_abuse} | ||
if block_size: | ||
extra_args["chunksize"] = block_size | ||
|
||
|
@@ -577,7 +582,9 @@ def _gdrive_open_file(self, item_id): | |
param = {"id": item_id} | ||
# it does not create a file on the remote | ||
gdrive_file = self.client.CreateFile(param) | ||
fd = gdrive_file.GetContentIOBuffer() | ||
fd = gdrive_file.GetContentIOBuffer( | ||
acknowledge_abuse=self._acknowledge_abuse | ||
) | ||
return IterStream(iter(fd)) | ||
|
||
def rm_file(self, path): | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
Decided not to add this flag to
GetContentString
for now because it is tiny bit more involved and we have no use for it anyway.Also didn't add
GetContentIOBuffer
to this doc, because it is not documented at all yet 🙁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.
let's add https://developers.google.com/drive/api/v3/reference/files/get#acknowledgeAbuse
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.
@shcheklein I suppose you meant v2 https://developers.google.com/drive/api/v2/reference/files/get#acknowledgeAbuse . But I'm not sure how useful that is, who cares what we use internally.