Skip to content
This repository has been archived by the owner on Oct 16, 2022. It is now read-only.

Check mount points for existing snapshot directory #537

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/Core/SnapshotRepo.vala
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ public class SnapshotRepo : GLib.Object{
return path_combine(timeshift_path, "snapshots");
}
}

public string custom_timeshift_path(string path){
if (btrfs_mode){
return path_combine(path, "timeshift-btrfs");
}
else{
return path_combine(path, "timeshift");
}
}

public string custom_snapshots_path(string path){
return path_combine(custom_timeshift_path(path), "snapshots");
}

// load ---------------------------------------

Expand Down Expand Up @@ -279,15 +292,37 @@ public class SnapshotRepo : GLib.Object{
var mps = Device.get_device_mount_points(dev.uuid);

if (mps.size > 0){
return mps[0].mount_point;
if (mps.size == 1){
return mps[0].mount_point;
}
else{
foreach(var m in mps){
if (check_for_snapshots(m.mount_point)){
log_debug("Found existing snapshot dir");
return m.mount_point;
}
}
return mps[0].mount_point;
}
}
else{
Device.automount_udisks(dev.device, parent_window);

mps = Device.get_device_mount_points(dev.uuid);

if (mps.size > 0){
return mps[0].mount_point;
if (mps.size == 1){
return mps[0].mount_point;
}
else{
foreach(var m in mps){
if (check_for_snapshots(m.mount_point)){
log_debug("Found existing snapshot dir");
return m.mount_point;
}
}
return mps[0].mount_point;
}
}
else{
return "";
Expand Down Expand Up @@ -319,6 +354,16 @@ public class SnapshotRepo : GLib.Object{
return luks_unlocked;
}

public bool check_for_snapshots(string test_path){
log_debug("SnapshotRepo: check_for_snapshots()");

if ((device == null) || !dir_exists(custom_snapshots_path(test_path))){
return false;
}

return true;
}

public bool load_snapshots(){

log_debug("SnapshotRepo: load_snapshots()");
Expand Down