Fix database lockout caused by duplicate files in library (#1102)

This commit is contained in:
Aditya Chandel
2025-09-06 21:22:59 -06:00
committed by GitHub
parent c8e78d3bc8
commit 074d8d6e69
36 changed files with 1766 additions and 359 deletions
@@ -0,0 +1,36 @@
import {Injectable} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {DuplicateFileNotification} from './model/duplicate-file-notification.model';
@Injectable({
providedIn: 'root'
})
export class DuplicateFileService {
private duplicateFiles: DuplicateFileNotification[] = [];
private duplicateFilesSubject = new BehaviorSubject<DuplicateFileNotification[]>([]);
duplicateFiles$ = this.duplicateFilesSubject.asObservable();
addDuplicateFile(notification: DuplicateFileNotification) {
const exists = this.duplicateFiles.some(file =>
file.fullPath === notification.fullPath && file.libraryId === notification.libraryId
);
if (!exists) {
this.duplicateFiles.unshift(notification);
this.duplicateFilesSubject.next([...this.duplicateFiles]);
}
}
clearDuplicateFiles() {
this.duplicateFiles = [];
this.duplicateFilesSubject.next([]);
}
removeDuplicateFile(fullPath: string, libraryId: number) {
this.duplicateFiles = this.duplicateFiles.filter(file =>
!(file.fullPath === fullPath && file.libraryId === libraryId)
);
this.duplicateFilesSubject.next([...this.duplicateFiles]);
}
}