Skip to content

Commit 85a064d

Browse files
marcelklehrMarcelRobitaille
authored andcommitted
fix(GoogleDriveAPIService): Make sure target path is not a shared folder
1 parent db4fad6 commit 85a064d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/Service/GoogleDriveAPIService.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@ public function importDriveJob(string $userId): void {
168168
// import batch of files
169169
$targetPath = $this->config->getUserValue($userId, Application::APP_ID, 'drive_output_dir', '/Google Drive');
170170
$targetPath = $targetPath ?: '/Google Drive';
171+
172+
try {
173+
$targetNode = $this->root->getUserFolder($userId)->get($targetPath);
174+
if ($targetNode->isShared()) {
175+
$this->logger->error('Target path ' . $targetPath . 'is shared, resorting to user root folder');
176+
$targetPath = '/';
177+
}
178+
} catch (NotFoundException) {
179+
// noop, folder doesn't exist
180+
} catch (NotPermittedException) {
181+
$this->logger->error('Cannot determine if target path ' . $targetPath . 'is shared, resorting to root folder');
182+
$targetPath = '/';
183+
}
184+
171185
// get progress
172186
$directoryProgressStr = $this->config->getUserValue($userId, Application::APP_ID, 'directory_progress', '[]');
173187
$directoryProgress = ($directoryProgressStr === '' || $directoryProgressStr === '[]')

0 commit comments

Comments
 (0)