]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- ignore requests to delete special snapshots
authorArvin Schnell <aschnell@suse.de>
Tue, 16 Oct 2018 12:04:45 +0000 (14:04 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 16 Oct 2018 12:04:45 +0000 (14:04 +0200)
LIBVERSION
doc/dbus-protocol.txt
snapper/Filesystem.cc
snapper/Snapper.cc
snapper/Snapshot.cc

index 80895903a15c8a6a7df7ca72da9a3ed78fe07eca..f77856a6f1af5be6984fa25aaa2e17616e1030ab 100644 (file)
@@ -1 +1 @@
-4.3.0
+4.3.1
index b4801a4ef5a2663c7e6358e9a007eb1b438fb21c..94dbd4515c2c91dd96a2af4885a27c7e0530aa37 100644 (file)
@@ -69,3 +69,7 @@ hexadecimal as "\x??". As a consequence "\" must be encoded as "\\".
 
 Due to security concerns there are no methods to get, compare or revert
 files. This can be done in the client.
+
+
+Some snapshots cannot be deleted (current, default and active). Delete
+requests for these are ignored.
index 6c70552330f78f3495e7550f25155bd870be2de8..c01961ab5b7997b896e71953f8adfeefa8943893 100644 (file)
@@ -174,16 +174,14 @@ namespace snapper
     bool
     Filesystem::isDefault(unsigned int num) const
     {
-       SN_THROW(UnsupportedException());
-       __builtin_unreachable();
+       return false;
     }
 
 
     std::pair<bool, unsigned int>
     Filesystem::getDefault() const
     {
-       SN_THROW(UnsupportedException());
-       __builtin_unreachable();
+       return std::make_pair(false, 0);
     }
 
 
@@ -198,16 +196,14 @@ namespace snapper
     std::pair<bool, unsigned int>
     Filesystem::getActive() const
     {
-       SN_THROW(UnsupportedException());
-       __builtin_unreachable();
+       return std::make_pair(false, 0);
     }
 
 
     bool
     Filesystem::isActive(unsigned int num) const
     {
-       SN_THROW(UnsupportedException());
-       __builtin_unreachable();
+       return false;
     }
 
 
index 5a0e10fb90b40ac47263ed95b20b2072a4867aa1..43c6da2dbce4d503bcdbfa90f89673a1ee89e221 100644 (file)
@@ -420,11 +420,15 @@ namespace snapper
        Hooks::delete_config(snapper->subvolumeDir(), snapper->getFilesystem());
 
        Snapshots& snapshots = snapper->getSnapshots();
+
+       Snapshots::const_iterator default_snapshot = snapshots.getDefault();
+       Snapshots::const_iterator active_snapshot = snapshots.getActive();
+
        for (Snapshots::iterator it = snapshots.begin(); it != snapshots.end(); )
        {
            Snapshots::iterator tmp = it++;
 
-           if (tmp->isCurrent())
+           if (tmp->isCurrent() || tmp == default_snapshot || tmp == active_snapshot)
                continue;
 
            try
index 985440f1f2cfc9e5e908aa24ae5b9b7807aaaee2..900e4ef2e89bedb53c4ebf22fa930396dccf4d0b 100644 (file)
@@ -573,9 +573,6 @@ namespace snapper
     void
     Snapshot::deleteFilesystemSnapshot() const
     {
-       if (isCurrent())
-           SN_THROW(IllegalSnapshotException());
-
        snapper->getFilesystem()->umountSnapshot(num);
        snapper->getFilesystem()->deleteSnapshot(num);
     }
@@ -734,7 +731,8 @@ namespace snapper
     void
     Snapshots::deleteSnapshot(iterator snapshot)
     {
-       if (snapshot == entries.end() || snapshot->isCurrent())
+       if (snapshot == entries.end() || snapshot->isCurrent() || snapshot->isDefault() ||
+           snapshot->isActive())
            SN_THROW(IllegalSnapshotException());
 
        snapshot->deleteFilesystemSnapshot();