Closed samkhan13 closed 3 years ago
The initial design was to append each row one by one, but I changed that to cache it in a list and flush it all at once because of performance issues. Each time you call appendRow, it's a call to the google api which drastically slows down the script, I wouldn't mind if there were no time out at 6min. It'd work for drives where there are not a lot of files, but for me, who has more than 500 files, the initial script was timing out all the time and even in smaller drives with about 150 files, it was timing out.
TBH, I didn't do any error management as I didn't get any error but I could add the error status (if any) in a new row of the sheet.
I understand your approach for spooling a list now. Yes maybe the only thing needed is a try-catch statement for errors. Thanks.
@samkhan13
I added some basic error catching, as I don't get any errors, I couldn't check how it behaves. Let me know if it works out for you this way :)
ef06dd80dd7a8f6a99f4b0346d669053cd64f677
cheers
@moya-a I ran into many problems while trying to get the desired results. Finding file permissions of all files and folders in a Drive is fairly complex challenge.
All of the problems I encountered with Drive API and DriveAPP API along with the suitable approach to overcoming time-out and other strange errors is documented here - https://github.com/samkhan13/gdrive-appscripts/blob/main/howToUse_pagedFilesList.md
Cheers :)
That's wierd, I'm not encountering any errors on the couple of drives I tested this script on
I'm interested in your solution but I cannot access your repo (getting 404)
hi, sorry i had forgotten to make the repo public. it should work now - https://github.com/samkhan13/gdrive-appscripts/blob/main/howToUse_pagedFilesList.md
using this script try running a querry with empty string or something like "'me' in owners"
. this will conduct a deep search.
Hi,
The problem of "Exception: The file or folder has invalid access settings." can be very strange.
Your current approach attempts to collect every file's permission within a list called
resultFiles
before writing to a google sheet. Due to this any errors encountered during a particular folder or a file cannot be debugged easily. Any successfully evaluated folders and files are lost.It would be worthwhile to instead append each row to the sheet. This would also prevent any timeout errors and internet connection problems while spooling
resultFiles
.Please have a look at
appendRow
function of this gist that recursively goes through folders and subfolders - https://gist.github.com/JavierCane/28f7307ceeaf6464431c1418b598a817Google changed the access permission methods at some point in the past. Prior to that a complex set of link sharing options could be assigned to a file or a folder. So some files and folders in a drive can have those older settings for access sharing and permissions, which are not a part of the current API.
In one of the folders that had this exception I found multiple share link settings in its share menu. I manually found that using the GUI after using the following code.
Please let me know if you are able to come up with a way to append each row to a sheet instead of collecting each row in a list. I wasn't able to do it myself to submit a pull request or a fork because I don't understand the logic for comparing the sharing access strings and sharing permissions strings in your current method.
Thank you.