notherbase-fs 3.3.3 → 3.3.5
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.
- package/models/spirit.js +8 -9
- package/package.json +1 -1
package/models/spirit.js
CHANGED
|
@@ -179,22 +179,21 @@ export default class Spirit {
|
|
|
179
179
|
* @param {Object} data Data to add to the backup.
|
|
180
180
|
*/
|
|
181
181
|
addBackup = async (data, max = 5) => {
|
|
182
|
-
if (!this.memory.data
|
|
182
|
+
if (!this.memory.data?._backupsEnabled) {
|
|
183
183
|
let oldData = this.memory.data;
|
|
184
184
|
this.memory.data = {
|
|
185
185
|
_backupsEnabled: true,
|
|
186
186
|
backups: [ oldData ]
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
|
-
else {
|
|
190
|
-
this.memory.data.backups.unshift({
|
|
191
|
-
_lastUpdate: Date.now(),
|
|
192
|
-
data: data
|
|
193
|
-
});
|
|
194
189
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
190
|
+
this.memory.data.backups.unshift({
|
|
191
|
+
_lastUpdate: Date.now(),
|
|
192
|
+
data: data
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
if (max > 1) {
|
|
196
|
+
while (this.memory.data.backups.length > max) this.memory.data.backups.pop();
|
|
198
197
|
}
|
|
199
198
|
}
|
|
200
199
|
};
|