implement check for missing locations

master
itwrx 1 year ago
parent a1b2743960
commit eee7038808
  1. 24
      models/routine.nim
  2. 8
      shared.nim
  3. 15
      views/routine_list.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.

@ -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 <https://www.gnu.org/licenses/> 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)

@ -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 = "<span color=\"#ff6b6b\" size=\"large\">Missing Source(s)/Destination(s) in selected Routine(s).</span>"
else:
createThread(thread, rsyncThread, list)
else:
Box {.expand: false.}:
orient = OrientY

Loading…
Cancel
Save