Skip to content

Commit 2138e1b

Browse files
committed
use @backup-nodes node
1 parent b1c0d2c commit 2138e1b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

node_backup.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@
44

55
p = c.p
66
if not p.h.startswith('@bk '):
7-
nd = p.insertAfter()
7+
nd = g.findNodeAnywhere(c, '@backup-nodes')
8+
if nd:
9+
nd = nd.insertAsNthChild(0)
10+
else:
11+
nd = p.insertAfter()
812
ts = time.strftime("%Y-%m-%d %H:%M:%S")
913
nd.h = "@bk %s %s" % (p.h, ts)
1014
s = '\n'.join(textwrap.wrap(
1115
base64.b64encode(p.b),
1216
break_long_words=True
1317
))
14-
nd.b = "# backup %s - %s\n\n%s" % (ts, p.h, s)
18+
nd.b = "# backup %s - %s\n# %s\n\n%s" % (
19+
ts, p.h, p.get_UNL(with_proto=True), s)
20+
g.es("%s - backed up"%ts)
1521
c.redraw()
1622
c.bodyWantsFocusNow()
1723

1824
else:
1925

20-
hdr, s = p.b.split('\n', 1)
26+
hdr, s = p.b.split('\n\n', 1)
2127
if hdr.startswith("# backup"): # decode
2228
hdr = hdr.replace('backup', 'BACKUP')
2329
p.b = "%s\n\n%s" % (

0 commit comments

Comments
 (0)