]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Remove source_path from BackupConfig 1102/head
authorCheng-Ling Lai <jamesljlster@gmail.com>
Sat, 7 Feb 2026 02:35:46 +0000 (10:35 +0800)
committerCheng-Ling Lai <jamesljlster@gmail.com>
Sat, 7 Feb 2026 03:10:31 +0000 (11:10 +0800)
client/snbk/BackupConfig.cc
client/snbk/BackupConfig.h
client/snbk/TheBigThing.cc
client/snbk/TheBigThing.h
client/snbk/cmd-list-configs.cc
client/snbk/cmd-list.cc

index 661b50416a1544c6675af95763df9968fc5b66aa..ba44596d56810ac2e21e2a45a8ea86f14428272d 100644 (file)
@@ -52,9 +52,6 @@ namespace snapper
        if (!toValue(tmp1, target_mode, false))
            SN_THROW(Exception(sformat("unknown target-mode '%s' in '%s'", tmp1.c_str(), name.c_str())));
 
-       if (!get_child_value(json_file.get_root(), "source-path", source_path))
-           SN_THROW(Exception(sformat("source-path entry not found in '%s'", name.c_str())));
-
        if (!get_child_value(json_file.get_root(), "target-path", target_path))
            SN_THROW(Exception(sformat("target-path entry not found in '%s'", name.c_str())));
 
index f92c3d37841a96401ad71627884354f03587426a..c3b47c1efd05743dd54bd41f833f849d484e3939 100644 (file)
@@ -57,7 +57,6 @@ namespace snapper
 
        TargetMode target_mode = TargetMode::LOCAL;
 
-       string source_path;
        string target_path;
 
        bool automatic = false;
index 9a7b8e4640282dc507749a8b3ecddc6864e16af9..dcec671ab790929e483c066e436d4691b3bf7bfe 100644 (file)
@@ -109,9 +109,10 @@ namespace snapper
            return nodes;
        }
 
-       string source_snapshot_dir(const BackupConfig& backup_config, unsigned int num)
+       string source_snapshot_dir(const ProxySnapper* snapper, unsigned int num)
        {
-           return backup_config.source_path + "/" SNAPSHOTS_NAME "/" + to_string(num);
+           return snapper->getConfig().getSubvolume() + "/" SNAPSHOTS_NAME "/" +
+                  to_string(num);
        }
 
        string target_snapshot_dir(const BackupConfig& backup_config, unsigned int num)
@@ -356,7 +357,7 @@ namespace snapper
        spec_source.shell = backup_config.get_source_shell();
        spec_source.mkdir_bin = MKDIR_BIN;
        spec_source.btrfs_bin = BTRFS_BIN;
-       spec_source.snapshot_dir = source_snapshot_dir(backup_config, num);
+       spec_source.snapshot_dir = source_snapshot_dir(the_big_things.snapper, num);
 
        CopySpec spec_target; // Copy specification for the snapshot on the target.
        spec_target.shell = backup_config.get_target_shell();
@@ -381,7 +382,8 @@ namespace snapper
                        the_big_things.source_tree.find_nearest_valid_node(source_uuid))
                {
                    spec_source.parent_subvol_path =
-                       source_snapshot_dir(backup_config, parent->node->get_number()) +
+                       source_snapshot_dir(the_big_things.snapper,
+                                           parent->node->get_number()) +
                        "/" SNAPSHOT_NAME;
                }
 
@@ -437,14 +439,6 @@ namespace snapper
          target_btrfs_version(backup_config.target_btrfs_bin, backup_config.get_target_shell()),
          snapper(snappers->getSnapper(backup_config.config)), locker(snapper)
     {
-       if (backup_config.source_path != snapper->getConfig().getSubvolume())
-       {
-           string error = sformat(_("Path mismatch between source-path of backup-config and subvolume of "
-                                    "snapper config ('%s' vs. '%s')."), backup_config.source_path.c_str(),
-                                  snapper->getConfig().getSubvolume().c_str());
-           SN_THROW(Exception(error));
-       }
-
        probe_source(backup_config, verbose);
        probe_target(backup_config, verbose);
 
@@ -479,8 +473,9 @@ namespace snapper
 
            // Query additional information (uuids, read-only) from btrfs.
 
-           CmdBtrfsSubvolumeShow extra(BTRFS_BIN, shell_source, backup_config.source_path + "/" SNAPSHOTS_NAME "/" +
-                                       to_string(num) + "/" SNAPSHOT_NAME);
+           CmdBtrfsSubvolumeShow extra(BTRFS_BIN, shell_source,
+                                       source_snapshot_dir(snapper, num) +
+                                           "/" SNAPSHOT_NAME);
 
            TheBigThing the_big_thing(num);
            the_big_thing.date = source_snapshot.getDate();
index 338bc6237ef8ee20f6e033739429bbd63a127723..7901467eaebed79d9a5330d4faa1c54e0d728a7d 100644 (file)
@@ -163,9 +163,10 @@ namespace snapper
        TreeView source_tree;
        TreeView target_tree;
 
+       const ProxySnapper* snapper;
+
     private:
 
-       const ProxySnapper* snapper;
        const Locker locker;
 
        vector<TheBigThing> the_big_things;
index 11e7958e3d1fc46abf48961022f4dee79d499c51..64364ba97c1d0fd744f0813da55edb2df6541473 100644 (file)
@@ -53,7 +53,7 @@ namespace snapper
 
        enum class Column
        {
-           NAME, CONFIG, TARGET_MODE, AUTOMATIC, SOURCE_PATH, TARGET_PATH, SSH_HOST,
+           NAME, CONFIG, TARGET_MODE, AUTOMATIC, TARGET_PATH, SSH_HOST,
            SSH_USER, SSH_PORT, SSH_IDENTITY, TARGET_BTRFS_BIN, TARGET_LS_BIN,
            TARGET_MKDIR_BIN, TARGET_RM_BIN, TARGET_RMDIR_BIN
        };
@@ -76,9 +76,6 @@ namespace snapper
                case Column::AUTOMATIC:
                    return Cell(_("Automatic"));
 
-               case Column::SOURCE_PATH:
-                   return Cell(_("Source Path"));
-
                case Column::TARGET_PATH:
                    return Cell(_("Target Path"));
 
@@ -132,9 +129,6 @@ namespace snapper
                case Column::AUTOMATIC:
                    return backup_config.automatic;
 
-               case Column::SOURCE_PATH:
-                   return backup_config.source_path;
-
                case Column::TARGET_PATH:
                    return backup_config.target_path;
 
@@ -290,11 +284,11 @@ namespace snapper
        }
 
        const vector<Column> some_columns = { Column::NAME, Column::CONFIG, Column::TARGET_MODE,
-           Column::AUTOMATIC, Column::SOURCE_PATH, Column::TARGET_PATH, Column::SSH_HOST,
+           Column::AUTOMATIC, Column::TARGET_PATH, Column::SSH_HOST,
            Column::SSH_USER, Column::SSH_PORT, Column::SSH_IDENTITY };
 
        const vector<Column> all_columns = { Column::NAME, Column::CONFIG, Column::TARGET_MODE,
-           Column::AUTOMATIC, Column::SOURCE_PATH, Column::TARGET_PATH, Column::SSH_HOST,
+           Column::AUTOMATIC, Column::TARGET_PATH, Column::SSH_HOST,
            Column::SSH_USER, Column::SSH_PORT, Column::SSH_IDENTITY, Column::TARGET_BTRFS_BIN,
            Column::TARGET_LS_BIN, Column::TARGET_MKDIR_BIN, Column::TARGET_RM_BIN,
            Column::TARGET_RMDIR_BIN
@@ -320,7 +314,7 @@ namespace snapper
     template <> struct EnumInfo<Column> { static const vector<string> names; };
 
     const vector<string> EnumInfo<Column>::names({
-       "name", "config", "target-mode", "automatic", "source-path", "target-path", "ssh-host",
+       "name", "config", "target-mode", "automatic", "target-path", "ssh-host",
        "ssh-user", "ssh-port", "ssh-identity", "target-btrfs-bin", "target-ls-bin",
        "target-mkdir-bin", "target-rm-bin", "target-rmdir-bin"
     });
index c0ed98f9c606e22961ac1159d158ddfe14b34d12..6b1ec7a31bedd90e2738415c647b8d1c997d9906 100644 (file)
@@ -232,8 +232,7 @@ namespace snapper
                if (backup_configs.size() > 1)
                {
                    cout << "Backup-config:" << backup_config.name << ", config:" << backup_config.config
-                        << ", source-path:" << backup_config.source_path << ", target-mode:"
-                        << toString(backup_config.target_mode) << endl;
+                        << ", target-mode:" << toString(backup_config.target_mode) << endl;
                }
 
                try