Merge branch 'check_src_dest_match'

master
itwrx 2 years ago
commit 20f480d253
  1. 34
      views/routine_list.nim

@ -36,6 +36,8 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
#i'm not sure if using threadvar here is needed, but doing it just in case. :)
var rsyncRunCmd {.threadvar.}: string
var rsyncRun {.threadvar.}: tuple[output: string, exitCode: int]
var rsyncCheckCmd {.threadvar.}: string
var rsyncCheckRun {.threadvar.}: tuple[output: string, exitCode: int]
var rsyncErrors: seq[string]
var routineRunCount: int
@ -48,9 +50,6 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
routineRuncount += 1
for source in routine.sources:
for destination in routine.destinations:
#per source/dest combo msgs still don't seem to be working right.
#maybe it requires a separate thread per combo? deprioritized.
#list.runStatus = "<span color=\"#FFE97B\" size=\"large\">Bkup " & source & " to " & destination & "...</span>"
#try without requiring superuser privs by default.
rsyncRunCmd = "rsync -aq " & source & " " & destination
rsyncRun = execCmdEx(rsyncRunCmd)
@ -66,16 +65,37 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
rsyncRun = execCmdEx(rsyncRunCmd)
if rsyncRun.exitCode != 0:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
#handle non-perms related error.
else:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
#explicitly check that sources were copied to destinations.
#just using file names, mod times, and size (same as bkup run itself).
rsyncCheckCmd = "rsync -rn " & source & " " & destination
rsyncCheckRun = execCmdEx(rsyncCheckCmd)
if rsyncCheckRun.exitCode != 0:
#handle permission denied error.
if rsyncCheckRun.exitCode == 23:
rsyncCheckRun.exitCode = 0
if getAskPassPath() == "":
let err = "No ssh-askpass binary found. Please install an ssh-askpass package for your distro, and let us know if EZ-Bkup still can't detect it's location."
rsyncErrors.add(err)
else:
rsyncCheckCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -rn " & source & " " & destination
rsyncCheckRun = execCmdEx(rsyncCheckCmd)
if rsyncCheckRun.exitCode != 0:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
#handle non-perms related error.
else:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
if rsyncErrors.len > 0:
list.runStatus = "<span color=\"#ff6b6b\" size=\"large\">Error! Please see the log at ~/.ez-bkup/errors.log</span>"
list.runStatus = "<span color=\"#ff6b6b\" size=\"large\">Error! Please see ~/.ez-bkup/errors.log</span>"
for err in rsyncErrors:
logger.log(lvlError, err)
elif routineRunCount == 0:
list.runStatus = "<span color=\"#FFA651\" size=\"large\">Meh. No Bkup Routines were run.</span>"
else:
list.runStatus = "<span color=\"#6fffa3\" size=\"large\">Bkup Complete!</span>"
list.runStatus = "<span color=\"#6fffa3\" size=\"large\">Bkup Complete!</span>"
list.redrawFromThread()
@ -214,8 +234,8 @@ method view(list: RoutineListState): Widget =
xAlign = 0
useMarkup = true
proc clicked() =
#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
#check that every source and destination exists for each routine or don't run bkup and show err status.
#locations not found will be logged. see routine.nim
var allLocationsExist: seq[bool]
for routine in list.routineModel.routineSeq():
if routine.id in list.selected:

Loading…
Cancel
Save