u2cli: dont enter delete stage if something failed

This commit is contained in:
ed 2023-04-20 20:40:09 +00:00
parent 6acf436573
commit 2459965ca8

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import print_function, unicode_literals from __future__ import print_function, unicode_literals
S_VERSION = "1.5" S_VERSION = "1.6"
S_BUILD_DT = "2023-03-12" S_BUILD_DT = "2023-04-20"
""" """
up2k.py: upload to copyparty up2k.py: upload to copyparty
@ -653,6 +653,7 @@ class Ctl(object):
return nfiles, nbytes return nfiles, nbytes
def __init__(self, ar, stats=None): def __init__(self, ar, stats=None):
self.ok = False
self.ar = ar self.ar = ar
self.stats = stats or self._scan() self.stats = stats or self._scan()
if not self.stats: if not self.stats:
@ -700,6 +701,8 @@ class Ctl(object):
self._fancy() self._fancy()
self.ok = True
def _safe(self): def _safe(self):
"""minimal basic slow boring fallback codepath""" """minimal basic slow boring fallback codepath"""
search = self.ar.s search = self.ar.s
@ -1131,11 +1134,13 @@ source file/folder selection uses rsync syntax, meaning that:
ctl = Ctl(ar) ctl = Ctl(ar)
if ar.dr and not ar.drd: if ar.dr and not ar.drd and ctl.ok:
print("\npass 2/2: delete") print("\npass 2/2: delete")
ar.drd = True ar.drd = True
ar.z = True ar.z = True
Ctl(ar, ctl.stats) ctl = Ctl(ar, ctl.stats)
sys.exit(0 if ctl.ok else 1)
if __name__ == "__main__": if __name__ == "__main__":