Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2021-05-09 23:39:49 +0300
committerPhie <phie@phie.ovh>2021-05-09 23:40:02 +0300
commit22ca8bed70f6677f5d0171118228c36baacfafb9 (patch)
tree725348985af3882cef82dc0dbe58831ea2cc42a0
parent23444f0e1fd1fe2beeb42322ce5539ba847affc6 (diff)
nextcloud isn't rising exceptions right, try to fix it'
-rwxr-xr-xlib/Controller/NoteController.php63
1 files changed, 34 insertions, 29 deletions
diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php
index a87e9d6..ae42835 100755
--- a/lib/Controller/NoteController.php
+++ b/lib/Controller/NoteController.php
@@ -1057,19 +1057,21 @@ public function getOpusEncoder(){
foreach($res['media'] as $media){
array_push($meta['media'], "./note/getmedia?note=".$path."&media=".$media);
}
- $file = $this->CarnetFolder->newFile($path);
//tried to do with a direct fopen on $file but lead to bad size on nextcloud
$tmppath = tempnam(sys_get_temp_dir(), uniqid().".sqd");
$zipFile->saveAsFile($tmppath);
$tmph = fopen($tmppath, "r");
if($tmph){
- try{
- $this->CarnetFolder->get($path)->delete();
- $file = $this->CarnetFolder->newFile($path);
+ if($this->CarnetFolder->nodeExists($path)){
+ try{
+ $this->CarnetFolder->get($path)->delete();
- } catch(\OCP\Files\NotFoundException $e) {
+ } catch(\OCP\Files\NotFoundException $e) {
+ }
}
-
+
+ $file = $this->CarnetFolder->newFile($path);
+
$file->putContent($tmph);
// Do not close $tmph, it is closed by putContent, and a log is displayed as
// fclose can not work
@@ -1222,33 +1224,36 @@ public function getOpusEncoder(){
$noteFolderName = "currentnote".$editUniqueID;
try{
-
- $noteNode = $this->CarnetFolder->get($path);
- if($noteNode->getType() === "dir"){
- $folder = $noteNode->copy($cache->getFullPath($noteFolderName));
- }
- else{
- $folder = $cache->newFolder($noteFolderName);
- $tmppath = tempnam(sys_get_temp_dir(), uniqid().".zip");
- file_put_contents($tmppath,$noteNode->fopen("r"));
- $zipFile = new \PhpZip\ZipFile();
- $zipFile->openFile($tmppath);
- foreach($zipFile as $entryName => $contents){
- if($entryName === ".extraction_finished")
- continue;
- if($contents === "" AND $zipFile->isDirectory($entryName)){
- $folder->newFolder($entryName);
- }
- else if($contents !== "" && $contents !== NULL){
- $parent = dirname($entryName);
- if($parent !== "." && !$folder->nodeExists($parent)){
- $folder->newFolder($parent);
+ if($this->CarnetFolder->nodeExists($path)){
+ $noteNode = $this->CarnetFolder->get($path);
+ if($noteNode->getType() === "dir"){
+ $folder = $noteNode->copy($cache->getFullPath($noteFolderName));
+ }
+ else{
+ $folder = $cache->newFolder($noteFolderName);
+ $tmppath = tempnam(sys_get_temp_dir(), uniqid().".zip");
+ file_put_contents($tmppath,$noteNode->fopen("r"));
+ $zipFile = new \PhpZip\ZipFile();
+ $zipFile->openFile($tmppath);
+ foreach($zipFile as $entryName => $contents){
+ if($entryName === ".extraction_finished")
+ continue;
+ if($contents === "" AND $zipFile->isDirectory($entryName)){
+ $folder->newFolder($entryName);
+ }
+ else if($contents !== "" && $contents !== NULL){
+ $parent = dirname($entryName);
+ if($parent !== "." && !$folder->nodeExists($parent)){
+ $folder->newFolder($parent);
+ }
+ $folder->newFile($entryName)->putContent($contents);
}
- $folder->newFile($entryName)->putContent($contents);
}
+ unlink($tmppath);
}
- unlink($tmppath);
}
+ else
+ $folder = $cache->newFolder($noteFolderName);
} catch(\OCP\Files\NotFoundException $e) {
$folder = $cache->newFolder($noteFolderName);
}