Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
821a485a20 | ||
|
|
2d9623c07c | ||
|
|
35afdf2164 | ||
|
|
807c8351c1 | ||
|
|
4ce99e89a4 | ||
|
|
b6e17451e3 | ||
|
|
9b007739ec | ||
|
|
e1f26ec966 | ||
|
|
1dd810c6b3 | ||
|
|
372a2076f4 | ||
|
|
aa5c03e8be | ||
|
|
3a94bde135 | ||
|
|
959bb7305f | ||
|
|
b183de6a93 | ||
|
|
7a5b129a07 | ||
|
|
608d289cdd |
22
CHANGELOG.md
22
CHANGELOG.md
@@ -1,12 +1,32 @@
|
||||
# Changelog
|
||||
|
||||
## 0.9.11 - 8-8-23
|
||||
### Changed
|
||||
- update owlkettle to fix buggy behavior of switches.
|
||||
- tweak AboutMenu text and bump version #.
|
||||
|
||||
## 0.9.10 - 8-6-23
|
||||
### Added
|
||||
- Added date and time for logged rsync errors. (ITwrx)
|
||||
- Handle spaces in directory/file names. (ITwrx)
|
||||
### Changed
|
||||
- moved Bkup status and button out of ScrolledWindow. (ITwrx)
|
||||
- fixed selected routines behavior. (ITwrx)
|
||||
|
||||
## 0.9.9 - 7-14-23
|
||||
### Added
|
||||
- Added org.itwrx.EZ-Bkup.png for window/workspace icon. (ITwrx)
|
||||
### Changed
|
||||
- refactored to use pkexec instead of ssh-askpass. (ITwrx)
|
||||
- Updated EZ-Bkup version in app_menu_button.nim. (ITwrx)
|
||||
|
||||
## 0.9.8 - 7-5-23
|
||||
### Added
|
||||
- Added icons and css paths that work with installed version in ez_bkup.nim. (ITwrx)
|
||||
### Changed
|
||||
- Made some file names more uniform. (ITwrx)
|
||||
- Re-added selectedPreload proc accidentally removed from Routine.nim in last release. (ITwrx)
|
||||
- Updated EZ-Bkup version in app_menu_button.nim and ez_bkup.desktop (included with installer in the funded release). (ITwrx)
|
||||
- Updated EZ-Bkup version in app_menu_button.nim. (ITwrx)
|
||||
|
||||
## 0.9.7 - 7-1-23
|
||||
### Added
|
||||
|
||||
@@ -18,6 +18,7 @@ method view(app: AppState): Widget =
|
||||
Window:
|
||||
title = APP_NAME
|
||||
defaultSize = (1024, 768)
|
||||
iconName = "org.itwrx.EZ-Bkup"
|
||||
HeaderBar {.addTitlebar.}:
|
||||
Icon {.addLeft.}:
|
||||
name = "ez_bkup"
|
||||
|
||||
20
shared.nim
20
shared.nim
@@ -4,7 +4,6 @@ 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
|
||||
#import "models/routine"
|
||||
|
||||
let appPath* = getHomeDir() & ".ez-bkup"
|
||||
let databasePath* = appPath & "/ez-bkup.sqlite"
|
||||
@@ -15,7 +14,6 @@ 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
|
||||
|
||||
proc writeErrorToLog*(logMsg: string) =
|
||||
logger.log(lvlError, logMsg)
|
||||
@@ -25,21 +23,3 @@ proc writeInfoToLog*(logMsg: string) =
|
||||
|
||||
proc hasCommas*(filename: string):bool =
|
||||
',' in filename
|
||||
|
||||
proc getAskPassPath*(): string =
|
||||
var askPassPath: string
|
||||
|
||||
if fileExists("/usr/libexec/openssh/ssh-askpass"):
|
||||
askPassPath = "/usr/libexec/openssh/ssh-askpass"
|
||||
elif fileExists("/usr/lib/openssh/gnome-ssh-askpass"):
|
||||
askPassPath = "/usr/lib/openssh/gnome-ssh-askpass"
|
||||
elif fileExists("/usr/lib/ssh/gtk-ssh-askpass"):
|
||||
askPassPath = "/usr/lib/ssh/gtk-ssh-askpass"
|
||||
elif fileExists("/usr/lib/ssh/ssh-askpass"):
|
||||
askPassPath = "/usr/lib/ssh/ssh-askpass"
|
||||
else:
|
||||
askPassPath = ""
|
||||
|
||||
return askPassPath
|
||||
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ method view(button: AppMenuButtonState): Widget =
|
||||
programName = "EZ-Bkup"
|
||||
logo = "ez_bkup"
|
||||
style = [StyleClass("about-dialog")]
|
||||
version = "0.9.8"
|
||||
version = "0.9.11"
|
||||
credits = @{
|
||||
"Created By": @["https://ITwrx.org"],
|
||||
"License": @["GPLv3"]
|
||||
"Created:": @["https://ITwrx.org"],
|
||||
"Src:": @["GPLv3"]
|
||||
}
|
||||
Label:
|
||||
text = "About EZ-Bkup"
|
||||
|
||||
@@ -4,7 +4,7 @@ EZ-Bkup is released under the General Public License 3.0.
|
||||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
import owlkettle
|
||||
import std/osproc, std/os, std/logging
|
||||
import osproc, os, logging, sequtils, times
|
||||
import edit_routine_dialog
|
||||
import "../models/routine", "../shared"
|
||||
|
||||
@@ -13,15 +13,10 @@ viewable RoutineList:
|
||||
runStatus: string
|
||||
selected: seq[RoutineId]
|
||||
|
||||
# hey, hook.
|
||||
hooks:
|
||||
# yes, you, the build hook.
|
||||
build:
|
||||
# i love you. :)
|
||||
state.selected = selectedPreload()
|
||||
|
||||
proc changed(state: bool)
|
||||
|
||||
var thread: Thread[RoutineListState]
|
||||
|
||||
proc rsyncThread(list: RoutineListState) {.thread.} =
|
||||
@@ -32,6 +27,8 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
|
||||
createDir(appPath)
|
||||
|
||||
var logger = newFileLogger(appPath & "/errors.log")
|
||||
let dt = now()
|
||||
let nowDT = dt.format("M-d-YYYY h:mm:ss tt")
|
||||
|
||||
#i'm not sure if using threadvar here is needed, but doing it just in case. :)
|
||||
var rsyncRunCmd {.threadvar.}: string
|
||||
@@ -51,49 +48,45 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
|
||||
for source in routine.sources:
|
||||
for destination in routine.destinations:
|
||||
#try without requiring superuser privs by default.
|
||||
rsyncRunCmd = "rsync -aq " & source & " " & destination
|
||||
#quote sources and destinations to handle possible spaces.
|
||||
rsyncRunCmd = "rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'"
|
||||
rsyncRun = execCmdEx(rsyncRunCmd)
|
||||
if rsyncRun.exitCode != 0:
|
||||
#handle permission denied error.
|
||||
if rsyncRun.exitCode == 23:
|
||||
rsyncRun.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:
|
||||
rsyncRunCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -aq " & source & " " & destination
|
||||
#quote sources and destinations to handle possible spaces.
|
||||
rsyncRunCmd = "pkexec rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'"
|
||||
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)
|
||||
rsyncErrors.add("(" & nowDT & ")" & "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)
|
||||
rsyncErrors.add("(" & nowDT & ")" & "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
|
||||
#quote sources and destinations to handle possible spaces.
|
||||
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
|
||||
#quote sources and destinations to handle possible spaces.
|
||||
rsyncCheckCmd = "pkexec 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)
|
||||
rsyncErrors.add("(" & nowDT & ")" & "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)
|
||||
rsyncErrors.add("(" & nowDT & ")" & "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 ~/.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>"
|
||||
list.runStatus = "<span color=\"#FFA651\" size=\"large\">No Bkup Routines were enabled. None were run.</span>"
|
||||
else:
|
||||
list.runStatus = "<span color=\"#6fffa3\" size=\"large\">Bkup Complete!</span>"
|
||||
|
||||
@@ -101,6 +94,10 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
|
||||
|
||||
method view(list: RoutineListState): Widget =
|
||||
result = gui:
|
||||
Box:
|
||||
orient = OrientY
|
||||
Box:
|
||||
orient = OrientY
|
||||
ScrolledWindow:
|
||||
Box:
|
||||
orient = OrientY
|
||||
@@ -116,7 +113,7 @@ method view(list: RoutineListState): Widget =
|
||||
margin = 6
|
||||
spacing = 6
|
||||
Switch {.expand: false, vAlign: AlignCenter.}:
|
||||
state = routine.selByDef
|
||||
state = sequtils.any(list.selected, proc (id: RoutineId): bool = id == routine.id)
|
||||
tooltip = "Enable/Disable this Routine for the current Bkup run."
|
||||
proc changed(state: bool) =
|
||||
if state == true:
|
||||
@@ -125,9 +122,6 @@ method view(list: RoutineListState): Widget =
|
||||
let index = list.selected.find(routine.id)
|
||||
if index != -1:
|
||||
list.selected.delete(index)
|
||||
|
||||
if not list.changed.isNil:
|
||||
list.changed.callback(true)
|
||||
Label:
|
||||
text = "<span size=\"large\">" & routine.name & "</span>"
|
||||
xAlign = 0
|
||||
@@ -146,12 +140,14 @@ method view(list: RoutineListState): Widget =
|
||||
if res.kind == DialogAccept:
|
||||
# The "Update" button was clicked
|
||||
list.routineModel.update(EditRoutineDialogState(state).routine)
|
||||
list.selected = selectedPreload()
|
||||
# Delete Button
|
||||
Button {.expand: false.}:
|
||||
icon = "user-trash-symbolic"
|
||||
tooltip = "Delete this Routine. Warning: will not ask you to confirm."
|
||||
proc clicked() =
|
||||
list.routineModel.delete(routine.id)
|
||||
list.selected = selectedPreload()
|
||||
if routine.id in list.selected:
|
||||
Box:
|
||||
orient = OrientY
|
||||
@@ -203,6 +199,25 @@ method view(list: RoutineListState): Widget =
|
||||
text = "<span color=\"#ff6b6b\">Routine will be ignored. Destination required.</span>"
|
||||
xAlign = 0
|
||||
useMarkup = true
|
||||
else:
|
||||
Box {.expand: false.}:
|
||||
orient = OrientY
|
||||
margin = 6
|
||||
spacing = 12
|
||||
Label:
|
||||
text = "<span size=\"large\">You don't have any Bkup Routines!!! 🙂</span>"
|
||||
xAlign = 0
|
||||
useMarkup = true
|
||||
Label:
|
||||
text = "<span size=\"large\">Please click on the + Routine button above to create your first Routine.</span>"
|
||||
xAlign = 0
|
||||
useMarkup = true
|
||||
|
||||
if list.routineModel.routineSeq().len() > 0:
|
||||
Box {.expand: false.}:
|
||||
orient = OrientY
|
||||
Box {.expand: false.}:
|
||||
orient = OrientY
|
||||
Box {.expand: false.}:
|
||||
orient = OrientX
|
||||
spacing = 6
|
||||
@@ -248,7 +263,12 @@ method view(list: RoutineListState): Widget =
|
||||
list.runStatus = "<span color=\"#ff6b6b\" size=\"large\">Missing Source(s)/Destination(s) in selected Routine(s).</span>"
|
||||
else:
|
||||
createThread(thread, rsyncThread, list)
|
||||
else:
|
||||
|
||||
#[if not list.routineModel.routineSeq().len() > 0:
|
||||
Box:
|
||||
orient = OrientX
|
||||
spacing = 6
|
||||
margin = 6
|
||||
Box {.expand: false.}:
|
||||
orient = OrientY
|
||||
margin = 6
|
||||
@@ -260,5 +280,5 @@ method view(list: RoutineListState): Widget =
|
||||
Label:
|
||||
text = "<span size=\"large\">Please click on the + Routine button above to create your first Routine.</span>"
|
||||
xAlign = 0
|
||||
useMarkup = true
|
||||
useMarkup = true]#
|
||||
export RoutineList
|
||||
|
||||
Reference in New Issue
Block a user