Skip to content

Commit

Permalink
Fix warning when creating the first snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Mar 23, 2024
1 parent 372448e commit aaf0e8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.10.1 (23 March, 2024)
* Fix warning when creating the first snapshot

# 0.10.0 (07 October, 2023)
* Fix warning generated during normal operation
* Fix support for target that is mounted as a subvolume by ignoring extra mount options
Expand Down
15 changes: 8 additions & 7 deletions just-backup-btrfs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use
* @author Nazar Mokrynskyi <[email protected]>
* @copyright Copyright (c) 2014-2023, Nazar Mokrynskyi
* @license http://opensource.org/licenses/MIT
* @version 0.10.0
* @version 0.10.1
*/
class Just_backup_btrfs {
/**
Expand Down Expand Up @@ -329,16 +329,17 @@ class Just_backup_btrfs {
* @param string $destination
* @param string $destination_external
*
* @return bool
* @return bool|string
*/
protected function get_last_common_snapshot ($history_db, $history_db_external, $destination, $destination_external) {
$snapshots = $history_db_external->query(
"SELECT `snapshot_name`
FROM `history`
ORDER BY `date` DESC"
);
while ($snapshot = $snapshots->fetchArray(SQLITE3_ASSOC)['snapshot_name']) {
$snapshot_escaped = $history_db::escapeString($snapshot);
while ($snapshot = $snapshots->fetchArray(SQLITE3_ASSOC)) {
$snapshot_name = $snapshot['snapshot_name'];
$snapshot_escaped = $history_db::escapeString($snapshot_name);
$snapshot_found = $history_db
->query(
"SELECT `snapshot_name`
Expand All @@ -348,10 +349,10 @@ class Just_backup_btrfs {
->fetchArray();
if (
$snapshot_found &&
file_exists("$destination/$snapshot") &&
file_exists("$destination_external/$snapshot")
file_exists("$destination/$snapshot_name") &&
file_exists("$destination_external/$snapshot_name")
) {
return $snapshot;
return $snapshot_name;
}
}
return false;
Expand Down

0 comments on commit aaf0e8f

Please sign in to comment.