Added option copysubfilesownedby any|me|others to `gam <UserTypeEntity> copy drivefile

This commit is contained in:
Ross Scroggs
2023-12-20 12:32:10 -08:00
parent f89f730957
commit 06a4c7a8c9
8 changed files with 42 additions and 12 deletions

View File

@@ -10,6 +10,12 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation
### 6.66.15
Added option `copysubfilesownedby any|me|others` to `gam <UserTypeEntity> copy drivefile` that allows
specification of which source folder sub files to copy based on file ownership; the default is `all`.
This only applies when files are being copied from a 'My Drive'.
### 6.66.14
Updated `gam <UserTypeEntity> modify messages` to recognize the following error:

View File

@@ -334,7 +334,7 @@ writes the credentials into the file oauth2.txt.
admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt
admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
GAMADV-XTD3 6.66.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.10.8 64-bit final
MacOS High Sierra 10.13.6 x86_64
@@ -1002,7 +1002,7 @@ writes the credentials into the file oauth2.txt.
C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt
C:\GAMADV-XTD3>gam version
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
GAMADV-XTD3 6.66.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
Windows-10-10.0.17134 AMD64

View File

@@ -68,6 +68,7 @@ gam <UserTypeEntity> copy drivefile <DriveFileEntity>
[mergewithparent [<Boolean>]] [recursive [depth <Number>]]
[copysubfiles [<Boolean>]] [filenamematchpattern <RegularExpression>]
[filemimetype [not] <MimeTypeList>]
[copysubfilesownedby any|me|others]
[copysubfolders [<Boolean>]] [foldernamematchpattern <RegularExpression>]
[copysubshortcuts [<Boolean>]] [shortcutnamematchpattern <RegularExpression>]
<DriveFileCopyAttribute>*
@@ -148,6 +149,11 @@ You can specify `<RegularExpression>` patterns that limit the items copied based
* `foldernamematchpattern <RegularExpression>` - Only folders whose name matches `<RegularExpression>` are copied
* `shortcutnamematchpattern <RegularExpression>` - Only shortcuts whose name matches `<RegularExpression>` are copied
### By default, when copying sub files, all files, regardless of ownership, are copied.
* `copysubfilesownedby all` - All files, regardless of ownership, are copied.
* `copysubfilesownedby me` - Only files owned by `<UserTypeEntity>` are copied.
* `copysubfilesownedby others` - Only files not owned by `<UserTypeEntity>` are copied.
### Specify a new name for the file/folder
* `newfilename <DriveFileName>` - The copied file/folder will be named `<DriveFileName>`
* If `stripnameprefix <String>` is specified, `<String>` will be stripped from the front of `<DriveFileName>`

View File

@@ -204,6 +204,9 @@ You can also replace ` ` with `-` but it doesn't seem to be required.
* `query "label:Foo -Bar-"` - Select messages with label `Foo (Bar)`
You can have GAM do the substitutions for you with the `matchlabel <LabelName>` option.
* `matchlabel "Foo (Bar)"` is converted to `query "label:Foo -Bar-"`
## Draft messages
Add a draft message to a user's mailbox.
```

View File

@@ -4,7 +4,7 @@
Print the current version of Gam with details
```
gam version
GAMADV-XTD3 6.66.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64
@@ -16,7 +16,7 @@ Time: 2023-06-02T21:10:00-07:00
Print the current version of Gam with details and time offset information
```
gam version timeoffset
GAMADV-XTD3 6.66.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64
@@ -28,7 +28,7 @@ Your system time differs from www.googleapis.com by less than 1 second
Print the current version of Gam with extended details and SSL information
```
gam version extended
GAMADV-XTD3 6.66.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.66.15 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64
@@ -65,7 +65,7 @@ MacOS High Sierra 10.13.6 x86_64
Path: /Users/Admin/bin/gamadv-xtd3
Version Check:
Current: 5.35.08
Latest: 6.66.14
Latest: 6.66.15
echo $?
1
```
@@ -73,7 +73,7 @@ echo $?
Print the current version number without details
```
gam version simple
6.66.14
6.66.15
```
In Linux/MacOS you can do:
```
@@ -83,7 +83,7 @@ echo $VER
Print the current version of Gam and address of this Wiki
```
gam help
GAM 6.66.14 - https://github.com/taers232c/GAMADV-XTD3
GAM 6.66.15 - https://github.com/taers232c/GAMADV-XTD3
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64

View File

@@ -6006,7 +6006,9 @@ gam <UserTypeEntity> copy drivefile <DriveFileEntity>
[summary [<Boolean>]] [showpermissionmessages [<Boolean>]]
[<DriveFileParentAttribute>]
[mergewithparent [<Boolean>]] [recursive [depth <Number>]]
[copysubfiles [<Boolean>]] [filenamematchpattern <RegularExpression>] [filemimetype [not] <MimeTypeList>]
[copysubfiles [<Boolean>]] [filenamematchpattern <RegularExpression>]
[filemimetype [not] <MimeTypeList>]
[copysubfilesownedby any|me|others]
[copysubfolders [<Boolean>]] [foldernamematchpattern <RegularExpression>]
[copysubshortcuts [<Boolean>]] [shortcutnamematchpattern <RegularExpression>]
<DriveFileCopyAttribute>*

View File

@@ -2,6 +2,12 @@
Merged GAM-Team version
6.66.15
Added option `copysubfilesownedby any|me|others` to `gam <UserTypeEntity> copy drivefile` that allows
specification of which source folder sub files to copy based on file ownership; the default is `all`.
This only applies when files are being copied from a 'My Drive'.
6.66.14
Updated `gam <UserTypeEntity> modify messages` to recognize the following error:

View File

@@ -55263,6 +55263,7 @@ def initCopyMoveOptions(copyCmd):
'shortcutNameMatchPattern': None,
'fileMimeTypes': set(),
'notMimeTypes': False,
'copySubFilesOwnedBy': None,
}
DUPLICATE_FILE_CHOICES = {
@@ -55378,6 +55379,8 @@ def getCopyMoveOptions(myarg, copyMoveOptions):
copyMoveOptions['notMimeTypes'] = checkArgumentPresent('not')
for mimeType in getString(Cmd.OB_MIMETYPE_LIST).lower().replace(',', ' ').split():
copyMoveOptions['fileMimeTypes'].add(validateMimeType(mimeType))
elif myarg == 'copysubfilesownedby':
copyMoveOptions['copySubFilesOwnedBy'] = getChoice(SHOW_OWNED_BY_CHOICE_MAP, mapChoice=True)
else:
return False
return True
@@ -56100,7 +56103,7 @@ def copyDriveFile(users):
entityActionFailedWarning(kvList+[Ent.DRIVE_FILE_SHORTCUT, childName], str(e), k, kcount)
_incrStatistic(statistics, STAT_FILE_FAILED)
def _checkChildCopyAllowed(childMimeType, childName):
def _checkChildCopyAllowed(childMimeType, childName, child):
if childMimeType == MIMETYPE_GA_FOLDER:
if not copyMoveOptions['copySubFolders']:
return False
@@ -56112,6 +56115,9 @@ def copyDriveFile(users):
else:
if not copyMoveOptions['copySubFiles']:
return False
if copyMoveOptions['copySubFilesOwnedBy'] is not None:
if child.get('driveId', None) is None and child.get('ownedByMe', False) != copyMoveOptions['copySubFilesOwnedBy']:
return False
if copyMoveOptions['fileMimeTypes']:
if not copyMoveOptions['notMimeTypes']:
if childMimeType not in copyMoveOptions['fileMimeTypes']:
@@ -56143,7 +56149,7 @@ def copyDriveFile(users):
q=WITH_PARENTS.format(folderId),
orderBy='folder desc,name,modifiedTime desc',
fields='nextPageToken,files(id,name,parents,appProperties,capabilities,contentHints,copyRequiresWriterPermission,'\
'description,folderColorRgb,mimeType,modifiedTime,properties,starred,driveId,trashed,viewedByMeTime,writersCanShare,'\
'description,folderColorRgb,mimeType,modifiedTime,ownedByMe,properties,starred,driveId,trashed,viewedByMeTime,writersCanShare,'\
'shortcutDetails(targetId,targetMimeType))',
pageSize=GC.Values[GC.DRIVE_MAX_RESULTS], **sourceSearchArgs)
kcount = len(sourceChildren)
@@ -56169,10 +56175,11 @@ def copyDriveFile(users):
if childId in copiedTargetFiles: # Don't recopy file/folder copied into a sub-folder
continue
kvList = [Ent.USER, user, _getEntityMimeType(child), childNameId]
if not _checkChildCopyAllowed(childMimeType, childName):
if not _checkChildCopyAllowed(childMimeType, childName, child):
if not suppressNotSelectedMessages:
entityActionNotPerformedWarning(kvList, Msg.NOT_SELECTED, k, kcount)
continue
child.pop('ownedByMe', None)
trashed = child.pop('trashed', False)
if (childId == newFolderId) or (excludeTrashed and trashed):
entityActionNotPerformedWarning(kvList,