diff options
author | Phie <phie@phie.ovh> | 2019-10-05 18:07:37 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2019-10-05 18:07:37 +0300 |
commit | 58f6b261b4fcc485c7578b5af51ac64eaaafb41b (patch) | |
tree | 337e148338e67918c50f43f71df90262773bee8a | |
parent | e553523e97c4657bc8bb8ee9a54cee6666190d7a (diff) |
avoid exception + infinite loop
-rwxr-xr-x | appinfo/info.xml | 2 | ||||
-rwxr-xr-x | lib/Controller/NoteController.php | 23 |
2 files changed, 20 insertions, 5 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml index 42b77e6..1183635 100755 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -19,7 +19,7 @@ Mac, with sync capabilities - Statistics : words/sentences/characters - Sync with ownCloud/NextCloud - Online editor as a ownCloud/NextCloud App]]></description> - <version>0.18.3</version> + <version>0.18.4</version> <licence>agpl</licence> <author mail="phie@phie.ovh" >Phie</author> <namespace>Carnet</namespace> diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php index ca354ac..93ba44f 100755 --- a/lib/Controller/NoteController.php +++ b/lib/Controller/NoteController.php @@ -873,11 +873,14 @@ public function getOpusEncoder(){ private function waitEndOfExtraction($id){ $cache = $this->getCacheFolder(); + $i=0; do{ if($cache->nodeExists("currentnote".$id."/.extraction_finished")) return; - sleep(1); - }while(true); + sleep(1); + $i++; + }while($i < 30); + throw new Exception ("timeout"); } @@ -923,10 +926,15 @@ public function getOpusEncoder(){ */ foreach($cache->getDirectoryListing() as $in){ if(substr($in->getName(), 0, strlen("currentnote")) === "currentnote"){ - $in->delete(); + try{ + $in->delete(); + } catch (\OCP\Lock\LockedException $e){ + + } } } $folder = $cache->newFolder("currentnote".$editUniqueID); + try{ $tmppath = tempnam(sys_get_temp_dir(), uniqid().".zip"); file_put_contents($tmppath,$this->CarnetFolder->get($path)->fopen("r")); @@ -949,7 +957,14 @@ public function getOpusEncoder(){ unlink($tmppath); } catch(\OCP\Files\NotFoundException $e) { } - $folder->newFile(".extraction_finished"); + + try{ + $folder->newFile(".extraction_finished"); + } catch (\OCP\Lock\LockedException $e){ + $folder->get(".extraction_finished")->unlock(\OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE); + $folder->newFile(".extraction_finished"); + + } } /** |