mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
Added option noduplicate to gam <UserTypeEntity> create drivefile
This commit is contained in:
@@ -12,6 +12,10 @@ See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Win
|
|||||||
|
|
||||||
### 6.65.09
|
### 6.65.09
|
||||||
|
|
||||||
|
Added option `noduplicate` to `gam <UserTypeEntity> create drivefile` that causes GAM
|
||||||
|
to issue a warning and not perform the create if a non-trashed item with the same name (regardless of MIME type)
|
||||||
|
exists in the parent folder.
|
||||||
|
|
||||||
Updated `gam <UserTypeEntity> get drivefile <DriveFileEntity>` to handle the following error
|
Updated `gam <UserTypeEntity> get drivefile <DriveFileEntity>` to handle the following error
|
||||||
that seems to occur when multiple tabs from a Google sheet are being downloaded in parallel.
|
that seems to occur when multiple tabs from a Google sheet are being downloaded in parallel.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ gam <UserTypeEntity> add calendaracls <UserCalendarEntity>
|
|||||||
gam <UserTypeEntity> update calendaracls <UserCalendarEntity>
|
gam <UserTypeEntity> update calendaracls <UserCalendarEntity>
|
||||||
<CalendarACLRole> <CalendarACLScopeEntity> [sendnotifications <Boolean>]
|
<CalendarACLRole> <CalendarACLScopeEntity> [sendnotifications <Boolean>]
|
||||||
gam <UserTypeEntity> delete calendaracls <UserCalendarEntity>
|
gam <UserTypeEntity> delete calendaracls <UserCalendarEntity>
|
||||||
<CalendarACLRole>] <CalendarACLScopeEntity>
|
[<CalendarACLRole>] <CalendarACLScopeEntity>
|
||||||
```
|
```
|
||||||
By default, when you add or update a calendar ACL, notification is sent to the members referenced in the `<CalendarACLScopeEntity>`.
|
By default, when you add or update a calendar ACL, notification is sent to the members referenced in the `<CalendarACLScopeEntity>`.
|
||||||
Use `sendnotifications false` to suppress sending the notification.
|
Use `sendnotifications false` to suppress sending the notification.
|
||||||
|
|||||||
@@ -165,7 +165,7 @@
|
|||||||
gam <UserTypeEntity> create|add drivefile
|
gam <UserTypeEntity> create|add drivefile
|
||||||
[(localfile <FileName>|-)|(url <URL>)]
|
[(localfile <FileName>|-)|(url <URL>)]
|
||||||
[(drivefilename|newfilename <DriveFileName>) | (replacefilename <RegularExpression> <String>)*]
|
[(drivefilename|newfilename <DriveFileName>) | (replacefilename <RegularExpression> <String>)*]
|
||||||
[stripnameprefix <String>]
|
[stripnameprefix <String>] [noduplicate]
|
||||||
<DriveFileCreateAttribute>*
|
<DriveFileCreateAttribute>*
|
||||||
[(csv [todrive <ToDriveAttribute>*] (addcsvdata <FieldName> <String>)*) |
|
[(csv [todrive <ToDriveAttribute>*] (addcsvdata <FieldName> <String>)*) |
|
||||||
(returnidonly|returnlinkonly|returneditlinkonly|showdetails)]
|
(returnidonly|returnlinkonly|returneditlinkonly|showdetails)]
|
||||||
@@ -201,6 +201,9 @@ These are the naming rules:
|
|||||||
|
|
||||||
If `stripnameprefix <String>` is specified, `<String>` will be stripped from the front of the Google Drive file name if present.
|
If `stripnameprefix <String>` is specified, `<String>` will be stripped from the front of the Google Drive file name if present.
|
||||||
|
|
||||||
|
If `noduplicate` is specfied, GAM will issue a warning and not perform the create if a non-trashed item with the same name (regardless of MIME type)
|
||||||
|
exists in the parent folder.
|
||||||
|
|
||||||
By default, when files are uploaded from local content, they are created with `binary` format, i.e., the data is uploaded
|
By default, when files are uploaded from local content, they are created with `binary` format, i.e., the data is uploaded
|
||||||
without any conversion. Standard GAM had an option `convert` that was passed to the Drive API v2 that it used.
|
without any conversion. Standard GAM had an option `convert` that was passed to the Drive API v2 that it used.
|
||||||
* convert - Whether to convert this file to the corresponding Docs Editors format
|
* convert - Whether to convert this file to the corresponding Docs Editors format
|
||||||
|
|||||||
@@ -5902,7 +5902,7 @@ gam <UserTypeEntity> print chatmessages [todrive <ToDriveAttribute>*] <ChatSpace
|
|||||||
gam <UserTypeEntity> create|add drivefile
|
gam <UserTypeEntity> create|add drivefile
|
||||||
[(localfile <FileName>|-)|(url <URL>)]
|
[(localfile <FileName>|-)|(url <URL>)]
|
||||||
[(drivefilename|newfilename <DriveFileName>) | (replacefilename <RegularExpression> <String>)*]
|
[(drivefilename|newfilename <DriveFileName>) | (replacefilename <RegularExpression> <String>)*]
|
||||||
[stripnameprefix <String>]
|
[stripnameprefix <String>] [noduplicate]
|
||||||
<DriveFileCreateAttribute>*
|
<DriveFileCreateAttribute>*
|
||||||
[(csv [todrive <ToDriveAttribute>*] (addcsvdata <FieldName> currenttime|<String>)*) |
|
[(csv [todrive <ToDriveAttribute>*] (addcsvdata <FieldName> currenttime|<String>)*) |
|
||||||
(returnidonly|returnlinkonly|returneditlinkonly|showdetails)]
|
(returnidonly|returnlinkonly|returneditlinkonly|showdetails)]
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ Merged GAM-Team version
|
|||||||
|
|
||||||
6.65.09
|
6.65.09
|
||||||
|
|
||||||
|
Added option `noduplicate` to `gam <UserTypeEntity> create drivefile` that causes GAM
|
||||||
|
to issue a warning and not perform the create if a non-trashed item with the same name (regardless of MIME type)
|
||||||
|
exists in the parent folder.
|
||||||
|
|
||||||
Updated `gam <UserTypeEntity> get drivefile <DriveFileEntity>` to handle the following error
|
Updated `gam <UserTypeEntity> get drivefile <DriveFileEntity>` to handle the following error
|
||||||
that seems to occur when multiple tabs from a Google sheet are being downloaded in parallel.
|
that seems to occur when multiple tabs from a Google sheet are being downloaded in parallel.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -9116,10 +9116,10 @@ def doCheckConnection():
|
|||||||
def doComment():
|
def doComment():
|
||||||
writeStdout(Cmd.QuotedArgumentList(Cmd.Remaining())+'\n')
|
writeStdout(Cmd.QuotedArgumentList(Cmd.Remaining())+'\n')
|
||||||
|
|
||||||
# gam version [check|checkrc|simple|extended] [timeoffset] [location <HostName>]
|
# gam version [check|checkrc|simple|extended] [timeoffset] [nooffseterror] [location <HostName>]
|
||||||
def doVersion(checkForArgs=True):
|
def doVersion(checkForArgs=True):
|
||||||
forceCheck = 0
|
forceCheck = 0
|
||||||
extended = timeOffset = simple = False
|
extended = noOffsetError = timeOffset = simple = False
|
||||||
testLocation = GOOGLE_TIMECHECK_LOCATION
|
testLocation = GOOGLE_TIMECHECK_LOCATION
|
||||||
if checkForArgs:
|
if checkForArgs:
|
||||||
while Cmd.ArgumentsRemaining():
|
while Cmd.ArgumentsRemaining():
|
||||||
@@ -9134,6 +9134,8 @@ def doVersion(checkForArgs=True):
|
|||||||
extended = timeOffset = True
|
extended = timeOffset = True
|
||||||
elif myarg == 'timeoffset':
|
elif myarg == 'timeoffset':
|
||||||
timeOffset = True
|
timeOffset = True
|
||||||
|
elif myarg == 'nooffseterror':
|
||||||
|
noOffsetError = True
|
||||||
elif myarg == 'location':
|
elif myarg == 'location':
|
||||||
testLocation = getString(Cmd.OB_HOST_NAME)
|
testLocation = getString(Cmd.OB_HOST_NAME)
|
||||||
else:
|
else:
|
||||||
@@ -9156,7 +9158,9 @@ def doVersion(checkForArgs=True):
|
|||||||
offsetSeconds, offsetFormatted = getLocalGoogleTimeOffset(testLocation)
|
offsetSeconds, offsetFormatted = getLocalGoogleTimeOffset(testLocation)
|
||||||
printKeyValueList([Msg.YOUR_SYSTEM_TIME_DIFFERS_FROM_GOOGLE.format(testLocation, offsetFormatted)])
|
printKeyValueList([Msg.YOUR_SYSTEM_TIME_DIFFERS_FROM_GOOGLE.format(testLocation, offsetFormatted)])
|
||||||
if offsetSeconds > MAX_LOCAL_GOOGLE_TIME_OFFSET:
|
if offsetSeconds > MAX_LOCAL_GOOGLE_TIME_OFFSET:
|
||||||
|
if not noOffsetError:
|
||||||
systemErrorExit(NETWORK_ERROR_RC, Msg.PLEASE_CORRECT_YOUR_SYSTEM_TIME)
|
systemErrorExit(NETWORK_ERROR_RC, Msg.PLEASE_CORRECT_YOUR_SYSTEM_TIME)
|
||||||
|
stderrWarningMsg(Msg.PLEASE_CORRECT_YOUR_SYSTEM_TIME)
|
||||||
if forceCheck:
|
if forceCheck:
|
||||||
doGAMCheckForUpdates(forceCheck)
|
doGAMCheckForUpdates(forceCheck)
|
||||||
if extended:
|
if extended:
|
||||||
@@ -53738,14 +53742,14 @@ createReturnItemMap = {
|
|||||||
# [(localfile <FileName>|-)|(url <URL>)]
|
# [(localfile <FileName>|-)|(url <URL>)]
|
||||||
# [(drivefilename|newfilename <DriveFileName>) | (replacefilename <RegularExpression> <String>)*]
|
# [(drivefilename|newfilename <DriveFileName>) | (replacefilename <RegularExpression> <String>)*]
|
||||||
# [stripnameprefix <String>]
|
# [stripnameprefix <String>]
|
||||||
# <DriveFileCreateAttribute>*
|
# <DriveFileCreateAttribute>* [noduplicate]
|
||||||
# [(csv [todrive <ToDriveAttribute>*] (addcsvdata <FieldName> <String>)*)) |
|
# [(csv [todrive <ToDriveAttribute>*] (addcsvdata <FieldName> <String>)*)) |
|
||||||
# (returnidonly|returnlinkonly|returneditlinkonly|showdetails)]
|
# (returnidonly|returnlinkonly|returneditlinkonly|showdetails)]
|
||||||
def createDriveFile(users):
|
def createDriveFile(users):
|
||||||
csvPF = media_body = None
|
csvPF = media_body = None
|
||||||
addCSVData = {}
|
addCSVData = {}
|
||||||
returnIdLink = None
|
returnIdLink = None
|
||||||
showDetails = False
|
noDuplicate = showDetails = False
|
||||||
body = {}
|
body = {}
|
||||||
newName = None
|
newName = None
|
||||||
assignLocalName = True
|
assignLocalName = True
|
||||||
@@ -53761,6 +53765,8 @@ def createDriveFile(users):
|
|||||||
elif myarg == 'showdetails':
|
elif myarg == 'showdetails':
|
||||||
returnIdLink = None
|
returnIdLink = None
|
||||||
showDetails = True
|
showDetails = True
|
||||||
|
elif myarg == 'noduplicate':
|
||||||
|
noDuplicate = True
|
||||||
elif myarg == 'csv':
|
elif myarg == 'csv':
|
||||||
csvPF = CSVPrintFile()
|
csvPF = CSVPrintFile()
|
||||||
elif csvPF and myarg == 'todrive':
|
elif csvPF and myarg == 'todrive':
|
||||||
@@ -53804,7 +53810,18 @@ def createDriveFile(users):
|
|||||||
continue
|
continue
|
||||||
if not _getDriveFileParentInfo(drive, user, i, count, body, parameters):
|
if not _getDriveFileParentInfo(drive, user, i, count, body, parameters):
|
||||||
continue
|
continue
|
||||||
|
entityType = _getEntityMimeType(body) if 'mimeType' in body else Ent.DRIVE_FILE
|
||||||
try:
|
try:
|
||||||
|
if noDuplicate:
|
||||||
|
# Check for existing file/folder, do not duplicate
|
||||||
|
files = callGAPIitems(drive.files(), 'list', 'files',
|
||||||
|
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID],
|
||||||
|
q=f"name = '{escapeDriveFileName(body['name'])}'and '{body['parents'][0]}' in parents and trashed = false",
|
||||||
|
fields='files(id)', **parameters['searchargs'])
|
||||||
|
if files:
|
||||||
|
entityActionNotPerformedWarning([Ent.USER, user, entityType, body['name'], Ent.DRIVE_PARENT_FOLDER_ID, body['parents'][0]],
|
||||||
|
f"{Msg.DUPLICATE} IDs {','.join([file['id'] for file in files])}", i, count)
|
||||||
|
continue
|
||||||
result = callGAPI(drive.files(), 'create',
|
result = callGAPI(drive.files(), 'create',
|
||||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FORBIDDEN, GAPI.INSUFFICIENT_PERMISSIONS, GAPI.INSUFFICIENT_PARENT_PERMISSIONS,
|
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FORBIDDEN, GAPI.INSUFFICIENT_PERMISSIONS, GAPI.INSUFFICIENT_PARENT_PERMISSIONS,
|
||||||
GAPI.INVALID, GAPI.BAD_REQUEST, GAPI.CANNOT_ADD_PARENT,
|
GAPI.INVALID, GAPI.BAD_REQUEST, GAPI.CANNOT_ADD_PARENT,
|
||||||
@@ -53846,10 +53863,10 @@ def createDriveFile(users):
|
|||||||
row.update(addCSVData)
|
row.update(addCSVData)
|
||||||
csvPF.WriteRow(row)
|
csvPF.WriteRow(row)
|
||||||
except (GAPI.forbidden, GAPI.insufficientFilePermissions, GAPI.insufficientParentPermissions,
|
except (GAPI.forbidden, GAPI.insufficientFilePermissions, GAPI.insufficientParentPermissions,
|
||||||
GAPI.invalid, GAPI.badRequest, GAPI.cannotAddParent,
|
GAPI.invalidQuery, GAPI.invalid, GAPI.badRequest, GAPI.cannotAddParent,
|
||||||
GAPI.fileNotFound, GAPI.unknownError, GAPI.storageQuotaExceeded, GAPI.teamDrivesSharingRestrictionNotAllowed,
|
GAPI.fileNotFound, GAPI.unknownError, GAPI.storageQuotaExceeded, GAPI.teamDrivesSharingRestrictionNotAllowed,
|
||||||
GAPI.teamDriveHierarchyTooDeep, GAPI.uploadTooLarge, GAPI.teamDrivesShortcutFileNotSupported) as e:
|
GAPI.teamDriveHierarchyTooDeep, GAPI.uploadTooLarge, GAPI.teamDrivesShortcutFileNotSupported) as e:
|
||||||
entityActionFailedWarning([Ent.USER, user, Ent.DRIVE_FILE_OR_FOLDER, body['name']], str(e), i, count)
|
entityActionFailedWarning([Ent.USER, user, entityType, body['name']], str(e), i, count)
|
||||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||||
userSvcNotApplicableOrDriveDisabled(user, str(e), i, count)
|
userSvcNotApplicableOrDriveDisabled(user, str(e), i, count)
|
||||||
if csvPF:
|
if csvPF:
|
||||||
|
|||||||
Reference in New Issue
Block a user