Commit 569ec2b5 authored by Michael Terry's avatar Michael Terry

Fix restoring specific files inside a symlinked folder

This also fixes backups with a symlinked .cache folder.

https://bugs.launchpad.net/deja-dup/+bug/1217959
parent 7384a1c1
Pipeline #49302 passed with stage
in 6 minutes and 18 seconds
......@@ -304,9 +304,17 @@ public class AssistantRestore : AssistantOperation
realize();
// Convert any specified files to a de-symlink-ified version, in case the
// user is sitting inside a symlinked folder.
var resolved_files = new GLib.List<File>();
foreach (File f in restore_files) {
resolved_files.append(DejaDup.try_realfile(f));
}
ensure_config_location();
var rest_op = new DejaDup.OperationRestore(config_location.get_backend(),
restore_location, date, restore_files);
restore_location, date,
resolved_files);
if (this.op_state != null)
rest_op.set_state(this.op_state);
......
......@@ -67,6 +67,7 @@ public class AssistantRestoreMissing : AssistantRestore {
* @param //File// ''list_dir'' Directory whose deleted files will be shown.
*/
private File list_directory;
private File display_directory;
private bool backups_queue_filled = false;
private static int compare_time(Time a, Time b) {
......@@ -118,7 +119,8 @@ public class AssistantRestoreMissing : AssistantRestore {
public AssistantRestoreMissing(File list_dir)
{
backend = DejaDup.Backend.get_default();
list_directory = list_dir;
display_directory = list_dir;
list_directory = DejaDup.try_realfile(list_dir);
}
protected override void add_custom_config_pages()
......@@ -208,7 +210,7 @@ public class AssistantRestoreMissing : AssistantRestore {
restore_files_remaining = restore_files.copy();
}
else if (page == listfiles_page) {
list_dir_label.label = list_directory.get_parse_name();
list_dir_label.label = display_directory.get_parse_name();
if (!scan_queue) {
do_query_files_at_date();
scan_queue = true;
......
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2019-01-04 23:05-0500\n"
"POT-Creation-Date: 2019-01-05 10:13-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
......@@ -777,5 +777,16 @@ public async void clean_tempdirs()
}
}
public string try_realpath(string input)
{
var resolved = Posix.realpath(input);
return resolved == null ? input : resolved;
}
public File try_realfile(File input)
{
return File.new_for_path(try_realpath(input.get_path()));
}
} // end namespace
......@@ -62,7 +62,7 @@ public class OperationVerify : Operation
if (nag)
job.flags |= ToolJob.Flags.NO_CACHE;
string cachedir = Environment.get_user_cache_dir();
string cachedir = try_realpath(Environment.get_user_cache_dir());
metadir = File.new_for_path(Path.build_filename(cachedir, Config.PACKAGE, "metadata"));
job.restore_files.append(metadir);
......
......@@ -462,7 +462,7 @@ internal class DuplicityJob : DejaDup.ToolJob
if (local_file == null) {
// Was not even a file path (maybe something goofy like computer://)
show_error(_("Could not restore ‘%s’: Not a valid file location").printf(
(restore_files.data as File).get_parse_name()));
restore_files.data.get_parse_name()));
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment