Created
March 6, 2019 14:20
-
-
Save pizzacat83/30ec2220e53de7d1ef711340f2f25ff3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const restoreItem = ({ id, isFolder }: { id: string; isFolder: boolean }): void => { | |
if (isFolder) { | |
throw new Error('Not implemented'); | |
} else { | |
const deletedFile = DriveApp.getFileById(id); | |
if (deletedFile.isTrashed()) { | |
const newFile = deletedFile.makeCopy(deletedFile.getName()); | |
const parents = deletedFile.getParents(); | |
while (parents.hasNext()) { | |
const parent = parents.next(); | |
parent.addFile(newFile); | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment