/*
* Copyright (c) [2011-2014] Novell, Inc.
- * Copyright (c) 2016 SUSE LLC
+ * Copyright (c) [2016,2018] SUSE LLC
*
* All Rights Reserved.
*
void filter(ProxySnapshots& snapshots, list<ProxySnapshots::iterator>& tmp) const;
+ // Removes snapshots that cannot be removed (e.g. btrfs active and default)
+ void filter_undeletables(ProxySnapshots& snapshots, list<ProxySnapshots::iterator>& tmp) const;
+
// Removes snapshots younger than parameters.min_age from tmp
void filter_min_age(ProxySnapshots& snapshots, list<ProxySnapshots::iterator>& tmp) const;
void
Cleaner::filter(ProxySnapshots& snapshots, list<ProxySnapshots::iterator>& tmp) const
{
+ filter_undeletables(snapshots, tmp);
filter_min_age(snapshots, tmp);
filter_pre_post(snapshots, tmp);
}
+void
+Cleaner::filter_undeletables(ProxySnapshots& snapshots, list<ProxySnapshots::iterator>& tmp) const
+{
+ vector<ProxySnapshots::const_iterator> undeletables;
+
+ ProxySnapshots::const_iterator default_snapshot = snapshots.getDefault();
+ if (default_snapshot != snapshots.end())
+ undeletables.push_back(default_snapshot);
+
+ ProxySnapshots::const_iterator active_snapshot = snapshots.getActive();
+ if (active_snapshot != snapshots.end())
+ undeletables.push_back(active_snapshot);
+
+ for (ProxySnapshots::const_iterator undeletable : undeletables)
+ {
+ list<ProxySnapshots::iterator>::iterator keep = find_if(tmp.begin(), tmp.end(),
+ [undeletable](ProxySnapshots::iterator it){ return undeletable->getNum() == it->getNum(); });
+
+ if (keep != tmp.end())
+ tmp.erase(keep);
+ }
+}
+
+
void
Cleaner::filter_min_age(ProxySnapshots& snapshots, list<ProxySnapshots::iterator>& tmp) const
{
{
const ProxySnapshots& snapshots = snapper->getSnapshots();
- ProxySnapshots::const_iterator default_snapshot = snapshots.end();
- ProxySnapshots::const_iterator active_snapshot = snapshots.end();
-
- try
- {
- default_snapshot = snapshots.getDefault();
- active_snapshot = snapshots.getActive();
- }
- catch (const UnsupportedException& e)
- {
- SN_CAUGHT(e);
- }
+ ProxySnapshots::const_iterator default_snapshot = snapshots.getDefault();
+ ProxySnapshots::const_iterator active_snapshot = snapshots.getActive();
if (list_mode != LM_ALL && list_mode != LM_SINGLE)
show_used_space = false;
}
+void
+filter_undeletables(ProxySnapshots& snapshots, vector<ProxySnapshots::iterator>& nums)
+{
+ vector<ProxySnapshots::const_iterator> undeletables;
+
+ undeletables.push_back(snapshots.begin());
+
+ ProxySnapshots::const_iterator default_snapshot = snapshots.getDefault();
+ if (default_snapshot != snapshots.end())
+ undeletables.push_back(default_snapshot);
+
+ ProxySnapshots::const_iterator active_snapshot = snapshots.getActive();
+ if (active_snapshot != snapshots.end())
+ undeletables.push_back(active_snapshot);
+
+ for (ProxySnapshots::const_iterator undeletable : undeletables)
+ {
+ vector<ProxySnapshots::iterator>::iterator keep = find_if(nums.begin(), nums.end(),
+ [undeletable](ProxySnapshots::iterator it){ return undeletable->getNum() == it->getNum(); });
+
+ if (keep != nums.end())
+ {
+ cerr << sformat(_("Cannot delete snapshot %d."), (*keep)->getNum()) << endl;
+ nums.erase(keep);
+ }
+ }
+}
+
+
void
command_delete(ProxySnappers* snappers, ProxySnapper* snapper)
{
}
}
+ filter_undeletables(snapshots, nums);
+
snapper->deleteSnapshots(nums, verbose);
if (sync)
+snapper (0.7.1) stable; urgency=low
+
+ * Updated to version 0.7.1
+
+ -- Arvin Schnell <aschnell@suse.com> Tue, 16 Oct 2018 14:02:07 +0200
+
snapper (0.6.0) stable; urgency=low
* Updated to version 0.6.0
<refentry id='snapper8'>
<refentryinfo>
- <date>2014-04-07</date>
+ <date>2018-10-16</date>
</refentryinfo>
<refmeta>
<refentrytitle>snapper</refentrytitle>
<manvolnum>8</manvolnum>
- <refmiscinfo class='date'>2014-04-07</refmiscinfo>
+ <refmiscinfo class='date'>2018-10-16</refmiscinfo>
<refmiscinfo class='version'>@VERSION@</refmiscinfo>
<refmiscinfo class='manual'>Filesystem Snapshot Management</refmiscinfo>
</refmeta>
</listitem>
</varlistentry>
</variablelist>
+ <para>Snapshot 0 cannot be deleted. For btrfs the currently
+ mounted snapshot and the snapshot that will be mounted next time
+ (the btrfs default subvolume) can also not be deleted.</para>
</listitem>
</varlistentry>
+-------------------------------------------------------------------
+Tue Oct 16 14:00:56 CEST 2018 - aschnell@suse.com
+
+- disallow to delete special (for btrfs currently mounted and next
+ to be mounted) snapshots (fate#326479)
+- version 0.7.1
+
-------------------------------------------------------------------
Thu Oct 11 11:10:11 CEST 2018 - aschnell@suse.com