diff --git a/models/routine.nim b/models/routine.nim
index 1e63ec1..f79cc97 100644
--- a/models/routine.nim
+++ b/models/routine.nim
@@ -43,6 +43,30 @@ proc seqToString(strSeq: seq[string]):string =
return newStr
+proc locationsExist*(routine: Routine): bool =
+ var logMsg: string
+ var exists: seq[int]
+ for source in routine.sources:
+ if dirExists(source) or fileExists(source):
+ exists.add(1)
+ else:
+ logMsg = "(" & nowDT & ")" & " Source not found: " & source
+ writeErrorToLog(logMsg)
+ exists.add(0)
+
+ for dest in routine.destinations:
+ if dirExists(dest) or fileExists(dest):
+ exists.add(1)
+ else:
+ logMsg = "(" & nowDT & ")" & " Destination not found: " & dest
+ writeErrorToLog(logMsg)
+ exists.add(0)
+
+ if 0 in exists:
+ return false
+ else:
+ return true
+
#[proc matches*(routine: Routine, filter: string): bool =
## Checks if the routine matches the given filter.
## This function is used to search the list of routines.
diff --git a/shared.nim b/shared.nim
index a93dd55..ced13e9 100644
--- a/shared.nim
+++ b/shared.nim
@@ -3,8 +3,8 @@ This file is part of EZ-Bkup.
EZ-Bkup is released under the General Public License 3.0.
See COPYING or for details.]#
-import logging, times, os, distros
-import "models/routine"
+import logging, times, os
+#import "models/routine"
let appPath* = getHomeDir() & ".ez-bkup"
let databasePath* = appPath & "/ez-bkup.sqlite"
@@ -14,8 +14,8 @@ if not dirExists(appPath):
var logger = newFileLogger(appPath & "/errors.log")
let dt = now()
-let nowDT = dt.format("M-d-YYYY h:mm:ss tt")
-var logMsg: string
+let nowDT* = dt.format("M-d-YYYY h:mm:ss tt")
+#var logMsg: string
proc writeErrorToLog*(logMsg: string) =
logger.log(lvlError, logMsg)
@@ -24,7 +24,7 @@ proc writeInfoToLog*(logMsg: string) =
logger.log(lvlInfo, logMsg)
proc hasCommas*(filename: string):bool =
- ',' in filename
+ ',' in filename
proc getAskPassPath*(): string =
var askPassPath: string
diff --git a/views/routine_list.nim b/views/routine_list.nim
index 7842264..ccc52db 100644
--- a/views/routine_list.nim
+++ b/views/routine_list.nim
@@ -212,7 +212,20 @@ method view(list: RoutineListState): Widget {.locks: "unknown".} =
xAlign = 0
useMarkup = true
proc clicked() =
- createThread(thread, rsyncThread, list)
+ #check that every source and destination exists for each routine or don't run bkup and show dialog.
+ #locations not found will be logged. see shared.nim
+ var allLocationsExist: seq[bool]
+ for routine in list.routineModel.routineSeq():
+ if routine.id in list.selected:
+ if locationsExist(routine) == true:
+ allLocationsExist.add(true)
+ else:
+ allLocationsExist.add(false)
+ if false in allLocationsExist:
+ #show error status.
+ list.runStatus = "Missing Source(s)/Destination(s) in selected Routine(s)."
+ else:
+ createThread(thread, rsyncThread, list)
else:
Box {.expand: false.}:
orient = OrientY