Skip to content

Commit

Permalink
refs #43 attempt to fix locked file during import
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
  • Loading branch information
Julien Veyssier committed Jan 5, 2021
1 parent ab0dc8e commit 18034b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>Google integration</name> <name>Google integration</name>
<summary>Import Google data into Nextcloud</summary> <summary>Import Google data into Nextcloud</summary>
<description><![CDATA[Google integration allows you to automatically import your Google calendars, contacts, photos and files into Nextcloud.]]></description> <description><![CDATA[Google integration allows you to automatically import your Google calendars, contacts, photos and files into Nextcloud.]]></description>
<version>0.1.4</version> <version>0.1.5</version>
<licence>agpl</licence> <licence>agpl</licence>
<author>Julien Veyssier</author> <author>Julien Veyssier</author>
<namespace>Google</namespace> <namespace>Google</namespace>
Expand Down
4 changes: 4 additions & 0 deletions lib/Service/GoogleDriveAPIService.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ private function getFile(string $accessToken, string $userId, array $fileItem, a
); );
return null; return null;
} }
$savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
$savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE);
$resource = $savedFile->fopen('w'); $resource = $savedFile->fopen('w');
$res = $this->googleApiService->simpleDownload($accessToken, $userId, $fileUrl, $resource); $res = $this->googleApiService->simpleDownload($accessToken, $userId, $fileUrl, $resource);
if (!isset($res['error'])) { if (!isset($res['error'])) {
Expand Down Expand Up @@ -397,6 +399,8 @@ private function getFile(string $accessToken, string $userId, array $fileItem, a
); );
return null; return null;
} }
$savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
$savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE);
$resource = $savedFile->fopen('w'); $resource = $savedFile->fopen('w');
$res = $this->googleApiService->simpleDownload($accessToken, $userId, $fileUrl, $resource, $params); $res = $this->googleApiService->simpleDownload($accessToken, $userId, $fileUrl, $resource, $params);
if (!isset($res['error'])) { if (!isset($res['error'])) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Service/GooglePhotosAPIService.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ private function getPhoto(string $accessToken, string $userId, array $photo, Nod
return null; return null;
} }
$savedFile = $albumFolder->newFile($photoName); $savedFile = $albumFolder->newFile($photoName);
$savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED);
$savedFile->unlock(\OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE);
$resource = $savedFile->fopen('w'); $resource = $savedFile->fopen('w');
$res = $this->googleApiService->simpleDownload($accessToken, $userId, $photoUrl, $resource); $res = $this->googleApiService->simpleDownload($accessToken, $userId, $photoUrl, $resource);
if (!isset($res['error'])) { if (!isset($res['error'])) {
Expand Down

0 comments on commit 18034b4

Please sign in to comment.