Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lib/Service/GoogleDriveAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ public function hasBeenCancelled(string $userId): bool {
* @throws Exception
*/
private function touchFolder(array $dirInfo): void {
if (!isset($dirInfo['node']) || !($dirInfo['node'] instanceof Folder)) {
return;
}
if (isset($dirInfo['modifiedTime']) && $dirInfo['modifiedTime'] !== null) {
$d = new DateTime($dirInfo['modifiedTime']);
$ts = $d->getTimestamp();
Expand Down Expand Up @@ -531,13 +534,18 @@ private function createDirsUnder(array &$directoriesById, Folder $currentFolder,
if (($currentFolderId === '' && !array_key_exists($parentId, $directoriesById))
|| $parentId === $currentFolderId) {
$name = $this->fileUtils->sanitizeFilename((string)($dir['name']), (string)$id);
if (!$currentFolder->nodeExists($name)) {
$newDir = $currentFolder->newFolder($name);
} else {
$newDir = $currentFolder->get($name);
if (!($newDir instanceof Folder)) {
return false;
try {
if (!$currentFolder->nodeExists($name)) {
$newDir = $currentFolder->newFolder($name);
} else {
$newDir = $currentFolder->get($name);
if (!($newDir instanceof Folder)) {
return false;
}
}
} catch (InvalidPathException) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the wrong Exception to catch?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original error was an InvalidPathException at least in my tests it threw an error here:

https://github.com/nextcloud/server/blob/83953c1e1297aa556647f32911ea59a84774e133/lib/private/Files/View.php#L1886-L1894

$this->logger->warning('Skipping Drive directory with invalid path', ['name' => $name, 'id' => $id, 'parentId' => $parentId]);
continue;
}
$directoriesById[$id]['node'] = $newDir;
$success = $this->createDirsUnder($directoriesById, $newDir, (string)$id);
Expand Down
Loading