Skip to content

Commit 4f9c14a

Browse files
swissspidyCopilot
andauthored
Update src/DB_Command_SQLite.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b532a03 commit 4f9c14a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/DB_Command_SQLite.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,16 @@ protected function sqlite_export( $file, $assoc_args ) {
343343
readfile( $export_db );
344344
unlink( $export_db );
345345
} else {
346-
rename( $export_db, $file );
346+
if ( ! @rename( $export_db, $file ) ) {
347+
// Clean up temporary files and surface a clear error if the export cannot be moved.
348+
if ( file_exists( $export_db ) ) {
349+
unlink( $export_db );
350+
}
351+
if ( file_exists( $temp_db ) ) {
352+
unlink( $temp_db );
353+
}
354+
WP_CLI::error( "Could not move exported database to '{$file}'. Please check that the path is writable and on the same filesystem." );
355+
}
347356
}
348357
unlink( $temp_db );
349358

0 commit comments

Comments
 (0)