From 18034b4c9560228ff9d42bd9094e4562a5400bec Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Tue, 5 Jan 2021 12:57:47 +0100 Subject: [PATCH] refs #43 attempt to fix locked file during import Signed-off-by: Julien Veyssier --- appinfo/info.xml | 2 +- lib/Service/GoogleDriveAPIService.php | 4 ++++ lib/Service/GooglePhotosAPIService.php | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 8cabc32a..dd96e71d 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -4,7 +4,7 @@ Google integration Import Google data into Nextcloud - 0.1.4 + 0.1.5 agpl Julien Veyssier Google diff --git a/lib/Service/GoogleDriveAPIService.php b/lib/Service/GoogleDriveAPIService.php index e5deda80..daf9d24f 100644 --- a/lib/Service/GoogleDriveAPIService.php +++ b/lib/Service/GoogleDriveAPIService.php @@ -340,6 +340,8 @@ private function getFile(string $accessToken, string $userId, array $fileItem, a ); return null; } + $savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED); + $savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE); $resource = $savedFile->fopen('w'); $res = $this->googleApiService->simpleDownload($accessToken, $userId, $fileUrl, $resource); if (!isset($res['error'])) { @@ -397,6 +399,8 @@ private function getFile(string $accessToken, string $userId, array $fileItem, a ); return null; } + $savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED); + $savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE); $resource = $savedFile->fopen('w'); $res = $this->googleApiService->simpleDownload($accessToken, $userId, $fileUrl, $resource, $params); if (!isset($res['error'])) { diff --git a/lib/Service/GooglePhotosAPIService.php b/lib/Service/GooglePhotosAPIService.php index c6e6532b..fc1d4eb7 100644 --- a/lib/Service/GooglePhotosAPIService.php +++ b/lib/Service/GooglePhotosAPIService.php @@ -363,6 +363,8 @@ private function getPhoto(string $accessToken, string $userId, array $photo, Nod return null; } $savedFile = $albumFolder->newFile($photoName); + $savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED); + $savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE); $resource = $savedFile->fopen('w'); $res = $this->googleApiService->simpleDownload($accessToken, $userId, $photoUrl, $resource); if (!isset($res['error'])) {