commit dddf609197f77ac3b24d403f384b1b9fc8c03911
parent c6700ae2aa8a1972d6e0ebae4170b958ee996dd1
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sat, 26 Oct 2024 16:23:24 +0200
fix: workaround issues when changing categories
Diffstat:
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/edit.php b/lib/edit.php
@@ -26,9 +26,11 @@ function edit_note(
/* if old and new filepaths differ, the file was likely renamed.
* delete the old one and return immediately */
- $deletion = false;
if ($filepath_t1 != $filepath_t0) {
- return delete_note($user, $category, basename($filepath_t1));
+ return rename(
+ $GLOBALS["data_dir"] . "/" . $user . "/" . $filepath_t1,
+ $GLOBALS["data_dir"] . "/" . $user . "/" . $filepath_t0
+ );
}
/* if all went fine, return "true" */
diff --git a/lib/read.php b/lib/read.php
@@ -24,6 +24,9 @@ function read_note(
/* Read from file */
$content = fread($file, $filesize);
+ /* close file-handle */
+ fclose($file);
+
} else {
$content = false;
diff --git a/lib/write.php b/lib/write.php
@@ -25,6 +25,9 @@ function write_note(
$filepath,
"w"
);
+ if ($file === false) {
+ return $file;
+ }
/* Write to file */
$bytes = fwrite(
@@ -32,7 +35,7 @@ function write_note(
$content
);
- /* close file-hanle */
+ /* close file-handle */
fclose($file);
/* return "true" on success and "false" otherwise */