tiro-notes 0.30.4-2.25 → 0.30.4-2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.js +7 -4
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -142,8 +142,11 @@ const startBackupScript = async (argsObj, dataFolder) => {
142
142
  const now = () => new Date().getTime()
143
143
  // if does not exists, create it, then give a timestamp of 0
144
144
  if (!tHelpers.fileExists(timestampFile)) await tHelpers.saveFile(timestampFile, "0")
145
- let lastBackupTimestampRaw = await tHelpers.openFile(timestampFile);
146
- let lastBackupTimestamp = parseInt(lastBackupTimestampRaw)
145
+ const getLastTimestamp = async () => {
146
+ let lastBackupTimestampRaw = await tHelpers.openFile(timestampFile);
147
+ let lastBackupTimestamp = parseInt(lastBackupTimestampRaw)
148
+ return lastBackupTimestamp
149
+ }
147
150
  let replaceTimestampCli = () => `echo ${now()} > '${timestampFile}'`
148
151
 
149
152
  // START INTERVAL
@@ -154,14 +157,14 @@ const startBackupScript = async (argsObj, dataFolder) => {
154
157
 
155
158
  let backupCli = `${replaceTimestampCli()}; mkdir '${backupFolder}'; mkdir '${backupFolder}/backups'; cd '${backupFolder}'; ${tarExec} --xz --verbose --create --file="backups/tiro.$(ls backups/ | wc -l | sed 's/^ *//;s/ *$//').tar.xz" '${dataFolder}' --listed-incremental='${backupFolder}metadata.snar'; ${postBackupScript}`
156
159
 
157
- const debugObj = {backupFolder, postBackupScriptFile, postBackupScript, lastBackupTimestamp, timeInterval, backupCli}
160
+ const debugObj = {backupFolder, postBackupScriptFile, postBackupScript, getLastTimestamp(), timeInterval, backupCli}
158
161
  console.log ("[BACKUP] starting backup logic!");
159
162
  console.log (debugObj);
160
163
 
161
164
  const debugBackupNow = isDev ? false : false
162
165
  const processBackupEveryDay = () => {
163
166
  // if > 1 day
164
- const diff = backupInterval + lastBackupTimestamp - new Date().getTime()
167
+ const diff = backupInterval + getLastTimestamp() - new Date().getTime()
165
168
  const diffMin = Math.round(diff / (1000 * 60))
166
169
  if (diff < 0 || debugBackupNow) {
167
170
  console.log(`[BACKUP] time has come, BACKUP!`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiro-notes",
3
- "version": "0.30.42.25",
3
+ "version": "0.30.42.26",
4
4
  "description": "Tiro Notes CLI to start Tiro Notes from the command line!",
5
5
  "scripts": {
6
6
  "dev": "ISDEV=true node cli.js",