From a7d5f7600645f835be989d59f07efbd0c000daf6 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 4 Sep 2018 21:57:38 +1000 Subject: [PATCH] Changed the way Tilde expansion is handeled in syncdir --- src/main.d | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.d b/src/main.d index d6ca9f3e..a047d793 100644 --- a/src/main.d +++ b/src/main.d @@ -1,6 +1,6 @@ import core.stdc.stdlib: EXIT_SUCCESS, EXIT_FAILURE; import core.memory, core.time, core.thread; -import std.getopt, std.file, std.path, std.process, std.stdio, std.conv; +import std.getopt, std.file, std.path, std.process, std.stdio, std.conv, std.algorithm.searching; import config, itemdb, monitor, onedrive, selective, sync, util; import std.net.curl: CurlException; static import log; @@ -205,12 +205,19 @@ int main(string[] args) // Set the local path OneDrive root string syncDir; - if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){ + // at this point we ahve already done Tilde expansion. + //if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){ // no shell or user set, so expandTilde() will fail +// syncDir = homePath ~ "OneDrive"; +// } else { +// // A shell and user is set +// syncDir = expandTilde(cfg.getValue("sync_dir")); +// } + // if the sync dir still contains a ~ after Tilde expansion, and + if (canFind(cfg.getValue("sync_dir"),"~") ) { syncDir = homePath ~ "OneDrive"; } else { - // A shell and user is set - syncDir = expandTilde(cfg.getValue("sync_dir")); + syncDir = cfg.getValue("sync_dir") ; } log.vlog("All operations will be performed in: ", syncDir); if (!exists(syncDir)) mkdirRecurse(syncDir);