Browse Source

* check whether ZIP operation completed successfully on close because ZipArchive will happily write into a nonexistent archive with no errors
* add .zip extension to output file if not present

Andrew Dolgov 1 month ago
parent
commit
6953ca02fd
1 changed files with 7 additions and 1 deletions
  1. 7 1
      init.php

+ 7 - 1
init.php

@@ -110,6 +110,9 @@ class Data_Migration extends Plugin {
 		if ($row = $sth->fetch()) {
 			$owner_uid = $row['id'];
 
+			if (stripos($output_file, ".zip") === FALSE)
+				$output_file = $output_file . ".zip";
+
 			Debug::log("exporting articles of user $user to $output_file...");
 
 			if ($only_marked)
@@ -151,7 +154,10 @@ class Data_Migration extends Plugin {
 					break;
 			}
 
-			$zip->close();
+			if ($zip->close() !== TRUE) {
+				Debug::log("write error while saving data to $output_file");
+				exit(3);
+			}
 
 			Debug::log("exported $total_processed articles to $output_file.");