mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
Add versioningLimit label support
This commit is contained in:
parent
898afb7ed7
commit
78bfc3341b
@ -1614,15 +1614,19 @@ class BNote extends AbstractBeccaEntity<BNote> {
|
|||||||
|
|
||||||
revision.setContent(noteContent);
|
revision.setContent(noteContent);
|
||||||
|
|
||||||
this.eraseExcessRevisions()
|
this.eraseExcessRevisionSnapshots()
|
||||||
return revision;
|
return revision;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit the number of Snapshots to revisionSnapshotNumberLimit
|
// Limit the number of Snapshots to revisionSnapshotNumberLimit
|
||||||
// Delete older Snapshots that exceed the limit
|
// Delete older Snapshots that exceed the limit
|
||||||
eraseExcessRevisions() {
|
eraseExcessRevisionSnapshots() {
|
||||||
const revisionSnapshotNumberLimit = parseInt(optionService.getOption('revisionSnapshotNumberLimit'));
|
// lable has a higher priority
|
||||||
|
let revisionSnapshotNumberLimit = parseInt(this.getLabelValue("versioningLimit") ?? "");
|
||||||
|
if (!Number.isInteger(revisionSnapshotNumberLimit)) {
|
||||||
|
revisionSnapshotNumberLimit = parseInt(optionService.getOption('revisionSnapshotNumberLimit'));
|
||||||
|
}
|
||||||
if (revisionSnapshotNumberLimit >= 0) {
|
if (revisionSnapshotNumberLimit >= 0) {
|
||||||
const revisions = this.getRevisions();
|
const revisions = this.getRevisions();
|
||||||
if (revisions.length - revisionSnapshotNumberLimit > 0) {
|
if (revisions.length - revisionSnapshotNumberLimit > 0) {
|
||||||
|
@ -116,7 +116,7 @@ function eraseRevision(req: Request) {
|
|||||||
function eraseAllExcessRevisions() {
|
function eraseAllExcessRevisions() {
|
||||||
let allNoteIds = sql.getRows('SELECT noteId FROM notes') as { noteId: string }[];
|
let allNoteIds = sql.getRows('SELECT noteId FROM notes') as { noteId: string }[];
|
||||||
allNoteIds.forEach(row => {
|
allNoteIds.forEach(row => {
|
||||||
becca.getNote(row.noteId)?.eraseExcessRevisions()
|
becca.getNote(row.noteId)?.eraseExcessRevisionSnapshots()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user