我正在尝试编写一个脚本来获取文件夹的当前编辑器并更改其权限,以便仅在最低级别的文件夹中查看。一切都运行正常,除了似乎将Google云端硬盘驱动器太长时间才能将顶级文件夹(仅查看)的权限应用于所有子文件夹。因此,TOP_FOLDER的编辑器,自从它继承自TOP_FOLDER以来最初具有对所有子文件夹的编辑权限,在我运行脚本时保留此访问权限,即使我在Drive中执行完全相同的操作时他们都拥有View只有在刷新页面后才能访问。
有没有人对如何解决这个问题有任何想法?
function fixFilePermissions() {
var oldEditors = TOP_FOLDER.getEditors();
TOP_FOLDER.addEditors(ADMINS);
//remove All but the admins
for each (var editor in oldEditors){
//if editor is not an admin
if(ADMINS.indexOf(editor) < 0){
//remove editor
TOP_FOLDER.removeEditor(editor);
//add back as viewer
TOP_FOLDER.addViewer(editor);
}
}
recFixFilePermissions(TOP_FOLDER);
}
function recFixFilePermissions(folder){
while(folder.getEditors().length > ADMINS.length){
Utilities.sleep(200);
Logger.log(folder.getEditors().length - ADMINS.length);
}
Logger.log("Folder: "+folder.getName());
Logger.log("Editors: "+folder.getEditors());
Logger.log("Viewers: "+folder.getViewers());
if(folder.getFolders().length > 0){
for each (subfolder in folder.getFolders()){
recFixFilePermissions(subfolder);
}
Logger.log("Has Subfolder");
}else{
for each (var person in folder.getViewers()){
folder.addEditor(person);
Logger.log("Gave " + person + " Edit Access to " + folder.getName());
}
}
}