]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Rearrange precondition checks for snapshot restore
authorCheng-Ling Lai <jameslai.tech@gmail.com>
Mon, 16 Feb 2026 07:59:27 +0000 (15:59 +0800)
committerCheng-Ling Lai <jameslai.tech@gmail.com>
Mon, 16 Mar 2026 14:52:20 +0000 (22:52 +0800)
client/snbk/TheBigThing.cc

index 812cf807b233e98fcc72be2cf4f25146add6a2fb..4d20e5c6697bff5b508ecd02b4c91e3929b88d18 100644 (file)
@@ -302,12 +302,12 @@ namespace snapper
        if (!quiet)
            cout << sformat(_("Restoring snapshot %d."), num) << '\n';
 
-       if (target_state != TargetState::VALID)
-           SN_THROW(Exception(_("Snapshot not on target.")));
-
        if (source_state != SourceState::MISSING)
            SN_THROW(Exception(_("Snapshot already on source.")));
 
+       if (target_state != TargetState::VALID)
+           SN_THROW(Exception(_("Snapshot not on target.")));
+
        // Copy the snapshot from the target to the source
        copy(backup_config, the_big_things,
             make_copy_specs(backup_config, the_big_things, CopyMode::TARGET_TO_SOURCE));