Permalink
Browse files

Store running backup filename in .runing_backup then use it to make s…

…ure we don't show partial backups in backups list.
  • Loading branch information...
1 parent f3374b0 commit 37eb48d88cf4be1e89cadda1e4dad845f6d43146 @willmot willmot committed Jan 14, 2012
Showing with 15 additions and 12 deletions.
  1. +1 −1 admin.actions.php
  2. +1 −1 admin.backup-button.php
  3. +1 −1 admin.backups-table.php
  4. +1 −1 admin.page.php
  5. +10 −7 functions/backup.functions.php
  6. +1 −1 readme.txt
View
@@ -206,7 +206,7 @@ function hmbkp_dismiss_error() {
*/
function hmbkp_ajax_is_backup_in_progress() {
- if ( ! hmbkp_is_in_progress() )
+ if ( ! hmbkp_in_progress() )
echo 0;
else
View
@@ -1,4 +1,4 @@
-<?php if ( hmbkp_is_in_progress() ) : ?>
+<?php if ( hmbkp_in_progress() ) : ?>
<a id="hmbkp_backup" class="add-new-h2 hmbkp_running" href="tools.php?page=<?php echo HMBKP_PLUGIN_SLUG; ?>&amp;action=hmbkp_cancel"><?php echo hmbkp_get_status(); ?> [cancel]</a>
View
@@ -1,7 +1,7 @@
<?php
// If max backups has changed
-if ( ! hmbkp_is_in_progress() )
+if ( ! hmbkp_in_progress() )
hmbkp_delete_old_backups();
if ( ( $backup_archives = hmbkp_get_backups() ) && count( $backup_archives ) ) : ?>
View
@@ -1,4 +1,4 @@
-<div class="wrap<?php if ( hmbkp_is_in_progress() ) { ?> hmbkp_running<?php } ?>">
+<div class="wrap<?php if ( hmbkp_in_progress() ) { ?> hmbkp_running<?php } ?>">
<?php screen_icon( 'backupwordpress' ); ?>
@@ -31,7 +31,7 @@ function hmbkp_do_backup() {
if ( ! $handle = @fopen( $file, 'w' ) )
return;
- fwrite( $handle, '' );
+ fwrite( $handle, HM_Backup::get_instance()->archive_filename() );
fclose( $handle );
@@ -59,7 +59,6 @@ function hmbkp_delete_old_backups() {
/**
* Returns an array of backup files
*
- * @todo exclude the currently running backup
* @todo use RecursiveDirectoryIterator
* @return array $files
*/
@@ -94,7 +93,11 @@ function hmbkp_get_backups() {
endif;
- krsort( $files );
+ ksort( $files );
+
+ // Don't include the currently running backup
+ if ( $key = array_search( trailingslashit( hmbkp_path() ) . hmbkp_in_progress(), $files ) )
+ unset( $files[$key] );
return $files;
}
@@ -175,7 +178,7 @@ function hmbkp_set_status( $message = '' ) {
if ( ! $handle = @fopen( $file, 'w' ) )
return;
- fwrite( $handle, $message );
+ fwrite( $handle, HM_Backup::get_instance()->archive_filename() . '::' . $message );
fclose( $handle );
@@ -191,7 +194,7 @@ function hmbkp_get_status() {
if ( ! file_exists( hmbkp_path() . '/.backup_running' ) )
return '';
- return file_get_contents( hmbkp_path() .'/.backup_running' );
+ return end( explode( '::', file_get_contents( hmbkp_path() . '/.backup_running' ) ) );
}
@@ -254,8 +257,8 @@ function hmbkp_valid_custom_excludes() {
*
* @return bool
*/
-function hmbkp_is_in_progress() {
- return file_exists( hmbkp_path() . '/.backup_running' );
+function hmbkp_in_progress() {
+ return file_exists( hmbkp_path() . '/.backup_running' ) ? reset( explode( '::', file_get_contents( hmbkp_path() .'/.backup_running' ) ) ) : '';
}
/**
View
@@ -111,7 +111,7 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
* Improved detection of zip and mysqldump command.
* Fix issues when `ABSPATH` is `/`.
* Remove relience on `SECURE_AUTH_KEY` as it's often not defined.
-* Use `warning()` not `error()` for issues reported by `zip`, `ZipArchive` or PclZip`.
+* Use `warning()` not `error()` for issues reported by `zip`, `ZipArchive` or `PclZip`.
* Fix download zip on Windows when `ABSPATH` contains a trailing forward slash.
* Send backup email after backup completes so that fatal errors in email code don't stop the backup from completing.
* Add missing / to `PCLZIP_TEMPORARY_DIR` define.

0 comments on commit 37eb48d

Please sign in to comment.