Fix database lockout caused by duplicate files in library (#1102)
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
<div class="dialog-container">
|
||||
<div class="info-message">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<p>{{ totalRecords }} duplicate file groups have been detected in your library. To maintain data integrity and ensure optimal performance, please review and remove these duplicate entries from your file system.</p>
|
||||
</div>
|
||||
|
||||
<div class="table-container">
|
||||
<p-table
|
||||
#dataTable
|
||||
[value]="(duplicateFiles$ | async) || []"
|
||||
[scrollable]="true"
|
||||
scrollHeight="100%"
|
||||
[paginator]="false"
|
||||
[rows]="15"
|
||||
[rowHover]="true">
|
||||
|
||||
<ng-template pTemplate="body" let-group>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="hash-group">
|
||||
<div class="hash-header">
|
||||
<i class="pi pi-copy"></i>
|
||||
<span class="hash-label">Hash:</span>
|
||||
<span class="hash-value">{{ group.hash }}</span>
|
||||
<span class="file-count">({{ group.files.length }} files)</span>
|
||||
</div>
|
||||
|
||||
<div class="files-list">
|
||||
@for (file of (group.files || []); track file.fullPath) {
|
||||
<div class="file-item-compact">
|
||||
<div class="file-icon">
|
||||
<i class="pi pi-file"></i>
|
||||
</div>
|
||||
<div class="file-details">
|
||||
<div class="filename">{{ file.fileName }}</div>
|
||||
<div class="file-path" [title]="file.fullPath">{{ file.fullPath }}</div>
|
||||
<div class="library-info">
|
||||
<i class="pi pi-database"></i>
|
||||
<span>{{ file.libraryName }}</span>
|
||||
<span class="timestamp">{{ file.timestamp | date:'short' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
|
||||
<ng-template pTemplate="emptymessage">
|
||||
<tr>
|
||||
<td class="empty-message">
|
||||
<div class="empty-content">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<span>No duplicate files detected</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
</p-table>
|
||||
</div>
|
||||
|
||||
<div class="bottom-fixed-area">
|
||||
<div class="paginator-container">
|
||||
<p-paginator
|
||||
[first]="first"
|
||||
[rows]="rows"
|
||||
[totalRecords]="totalRecords"
|
||||
[showCurrentPageReport]="true"
|
||||
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} duplicate file groups"
|
||||
(onPageChange)="onPageChange($event)">
|
||||
</p-paginator>
|
||||
</div>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
label="Acknowledge"
|
||||
icon="pi pi-check"
|
||||
(click)="acknowledgeAndClose()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
.dialog-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
margin-bottom: 100px;
|
||||
|
||||
::ng-deep .p-datatable {
|
||||
height: 100%;
|
||||
|
||||
.p-datatable-wrapper {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr > td {
|
||||
border: none !important;
|
||||
padding: 0.5rem 0.5rem;
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr {
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-fixed-area {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: var(--surface-ground);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.paginator-container {
|
||||
::ng-deep .p-paginator {
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.duplicate-files-content {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.hash-group {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.hash-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
padding-bottom: 0.5rem;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
|
||||
i {
|
||||
color: var(--primary-color);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.hash-label {
|
||||
font-weight: 600;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.hash-value {
|
||||
font-family: 'Courier New', monospace;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
font-size: 1rem;
|
||||
font-weight: 900;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.file-count {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.files-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.file-item-compact {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem;
|
||||
border-radius: 6px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
transition: all 0.2s ease;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.file-icon {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
i {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
.file-details {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.filename {
|
||||
font-family: 'Courier New', monospace;
|
||||
font-weight: 600;
|
||||
font-size: 0.95rem;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
word-break: break-word;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.file-path {
|
||||
font-size: 0.95rem;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
font-family: 'Courier New', monospace;
|
||||
word-break: break-all;
|
||||
line-height: 1.2;
|
||||
max-height: 2.4em;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.library-info {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
font-size: 0.9rem;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
margin-top: 0.1rem;
|
||||
|
||||
i {
|
||||
color: var(--primary-color);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
margin-left: auto;
|
||||
font-size: 0.8rem;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
}
|
||||
|
||||
.empty-message {
|
||||
text-align: center !important;
|
||||
padding: 3rem 1rem !important;
|
||||
|
||||
.empty-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
opacity: 0.6;
|
||||
|
||||
i {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.info-message {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
background: rgba(234, 88, 12, 0.1);
|
||||
border: 1px solid rgba(234, 88, 12, 0.3);
|
||||
border-radius: 0.375rem;
|
||||
color: #fbbf24;
|
||||
|
||||
i {
|
||||
color: #f59e0b;
|
||||
font-size: 1.125rem;
|
||||
margin-top: 0.125rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { DynamicDialogRef, DynamicDialogConfig } from 'primeng/dynamicdialog';
|
||||
import { TableModule } from 'primeng/table';
|
||||
import { ButtonModule } from 'primeng/button';
|
||||
import { TooltipModule } from 'primeng/tooltip';
|
||||
import { PaginatorModule } from 'primeng/paginator';
|
||||
import { Observable, map } from 'rxjs';
|
||||
import {DuplicateFileNotification} from '../../../shared/websocket/model/duplicate-file-notification.model';
|
||||
import {DuplicateFileService} from '../../../shared/websocket/duplicate-file.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-duplicate-files-dialog',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TableModule, ButtonModule, TooltipModule, PaginatorModule],
|
||||
templateUrl: './duplicate-files-dialog.component.html',
|
||||
styleUrls: ['./duplicate-files-dialog.component.scss']
|
||||
})
|
||||
export class DuplicateFilesDialogComponent implements OnInit {
|
||||
duplicateFiles$: Observable<{ hash: string; files: DuplicateFileNotification[] }[]>;
|
||||
totalRecords = 0;
|
||||
first = 0;
|
||||
rows = 15;
|
||||
|
||||
constructor(
|
||||
public ref: DynamicDialogRef,
|
||||
public config: DynamicDialogConfig,
|
||||
private duplicateFileService: DuplicateFileService
|
||||
) {
|
||||
this.duplicateFiles$ = this.config.data.duplicateFiles$.pipe(
|
||||
map((files: DuplicateFileNotification[] | null) => {
|
||||
if (!files) return [];
|
||||
|
||||
// Group files by hash
|
||||
const groupedFiles = files.reduce((acc, file) => {
|
||||
if (!acc[file.hash]) {
|
||||
acc[file.hash] = [];
|
||||
}
|
||||
acc[file.hash].push(file);
|
||||
return acc;
|
||||
}, {} as { [hash: string]: DuplicateFileNotification[] });
|
||||
|
||||
const groups = Object.entries(groupedFiles).map(([hash, files]) => ({
|
||||
hash,
|
||||
files: files.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime())
|
||||
}));
|
||||
|
||||
this.totalRecords = groups.length;
|
||||
return groups.slice(this.first, this.first + this.rows);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
onPageChange(event: any) {
|
||||
this.first = event.first;
|
||||
this.rows = event.rows;
|
||||
this.duplicateFiles$ = this.config.data.duplicateFiles$.pipe(
|
||||
map((files: DuplicateFileNotification[] | null) => {
|
||||
if (!files) return [];
|
||||
|
||||
const groupedFiles = files.reduce((acc, file) => {
|
||||
if (!acc[file.hash]) {
|
||||
acc[file.hash] = [];
|
||||
}
|
||||
acc[file.hash].push(file);
|
||||
return acc;
|
||||
}, {} as { [hash: string]: DuplicateFileNotification[] });
|
||||
|
||||
const groups = Object.entries(groupedFiles).map(([hash, files]) => ({
|
||||
hash,
|
||||
files: files.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime())
|
||||
}));
|
||||
|
||||
this.totalRecords = groups.length;
|
||||
return groups.slice(this.first, this.first + this.rows);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
acknowledgeAndClose() {
|
||||
this.duplicateFileService.clearDuplicateFiles();
|
||||
this.ref.close();
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
@if (duplicateFilesCount$ | async; as count) {
|
||||
@if (count > 0) {
|
||||
<div class="flex flex-col p-4 space-y-2 live-border">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-2">
|
||||
<i class="pi pi-exclamation-triangle text-yellow-500"></i>
|
||||
<span class="font-normal text-zinc-200">{{ count }} duplicate files detected</span>
|
||||
</div>
|
||||
<p-tag [value]="count.toString()" severity="warn" [rounded]="true"></p-tag>
|
||||
</div>
|
||||
<p-button
|
||||
label="View Details"
|
||||
icon="pi pi-list"
|
||||
outlined
|
||||
size="small"
|
||||
severity="info"
|
||||
fluid
|
||||
(click)="openDialog()">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
.duplicate-files-content {
|
||||
max-height: 500px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.live-border {
|
||||
border: 0.5px solid var(--primary-color);
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
import {Component, inject, OnDestroy} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {DialogModule} from 'primeng/dialog';
|
||||
import {ButtonModule} from 'primeng/button';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {TagModule} from 'primeng/tag';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {DuplicateFileService} from '../../../shared/websocket/duplicate-file.service';
|
||||
import {DuplicateFileNotification} from '../../../shared/websocket/model/duplicate-file-notification.model';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {DuplicateFilesDialogComponent} from './duplicate-files-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-duplicate-files-notification',
|
||||
standalone: true,
|
||||
imports: [CommonModule, DialogModule, ButtonModule, TableModule, TagModule],
|
||||
templateUrl: './duplicate-files-notification.component.html',
|
||||
styleUrls: ['./duplicate-files-notification.component.scss'],
|
||||
providers: [DialogService]
|
||||
})
|
||||
export class DuplicateFilesNotificationComponent implements OnDestroy {
|
||||
displayDialog = false;
|
||||
|
||||
private duplicateFileService = inject(DuplicateFileService);
|
||||
private ref: DynamicDialogRef | undefined;
|
||||
|
||||
duplicateFiles$ = this.duplicateFileService.duplicateFiles$;
|
||||
duplicateFilesCount$: Observable<number> = this.duplicateFiles$.pipe(
|
||||
map(files => files?.length || 0)
|
||||
);
|
||||
|
||||
constructor(
|
||||
private dialogService: DialogService
|
||||
) {
|
||||
}
|
||||
|
||||
openDialog() {
|
||||
this.ref = this.dialogService.open(DuplicateFilesDialogComponent, {
|
||||
header: 'Duplicate Files Detected',
|
||||
width: '80dvw',
|
||||
height: '75dvh',
|
||||
contentStyle: {overflow: 'hidden'},
|
||||
maximizable: true,
|
||||
modal: true,
|
||||
data: {
|
||||
duplicateFiles$: this.duplicateFiles$
|
||||
}
|
||||
});
|
||||
|
||||
this.ref.onClose.subscribe((result: any) => {
|
||||
if (result) {
|
||||
// Handle any result from dialog if needed
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.displayDialog = false;
|
||||
}
|
||||
|
||||
clearAllDuplicates() {
|
||||
this.duplicateFileService.clearDuplicateFiles();
|
||||
this.closeDialog();
|
||||
}
|
||||
|
||||
removeDuplicate(file: DuplicateFileNotification) {
|
||||
this.duplicateFileService.removeDuplicateFile(file.fullPath, file.libraryId);
|
||||
}
|
||||
|
||||
formatTimestamp(timestamp: string): string {
|
||||
return new Date(timestamp).toLocaleString();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.ref) {
|
||||
this.ref.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -1,5 +1,3 @@
|
||||
.live-border {
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--primary-color);
|
||||
border-radius: 0.5rem;
|
||||
border: 0.5px solid var(--primary-color);
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
.live-border {
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--primary-color);
|
||||
border-radius: 0.5rem;
|
||||
border: 0.5px solid var(--primary-color);
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -1,5 +1,8 @@
|
||||
<div class="metadata-progress-box flex gap-4 flex-col w-[25rem] max-h-[60vh] overflow-y-auto">
|
||||
<app-live-notification-box/>
|
||||
@if (hasDuplicateFiles$ | async) {
|
||||
<app-duplicate-files-notification/>
|
||||
}
|
||||
@if (hasActiveTasks$ | async) {
|
||||
<app-live-task-event-box/>
|
||||
}
|
||||
|
||||
+9
-1
@@ -8,6 +8,8 @@ import {map} from 'rxjs/operators';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {BookdropFilesWidgetComponent} from '../../../bookdrop/bookdrop-files-widget-component/bookdrop-files-widget.component';
|
||||
import {BookdropFileService} from '../../../bookdrop/bookdrop-file.service';
|
||||
import {DuplicateFilesNotificationComponent} from '../duplicate-files-notification/duplicate-files-notification.component';
|
||||
import {DuplicateFileService} from '../../../shared/websocket/duplicate-file.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-unified-notification-popover-component',
|
||||
@@ -16,7 +18,8 @@ import {BookdropFileService} from '../../../bookdrop/bookdrop-file.service';
|
||||
LiveTaskEventBoxComponent,
|
||||
MetadataProgressWidgetComponent,
|
||||
AsyncPipe,
|
||||
BookdropFilesWidgetComponent
|
||||
BookdropFilesWidgetComponent,
|
||||
DuplicateFilesNotificationComponent
|
||||
],
|
||||
templateUrl: './unified-notification-popover-component.html',
|
||||
standalone: true,
|
||||
@@ -25,6 +28,7 @@ import {BookdropFileService} from '../../../bookdrop/bookdrop-file.service';
|
||||
export class UnifiedNotificationBoxComponent {
|
||||
metadataProgressService = inject(MetadataProgressService);
|
||||
bookdropFileService = inject(BookdropFileService);
|
||||
duplicateFileService = inject(DuplicateFileService);
|
||||
taskEventService = inject(TaskEventService);
|
||||
|
||||
hasMetadataTasks$ = this.metadataProgressService.activeTasks$.pipe(
|
||||
@@ -33,6 +37,10 @@ export class UnifiedNotificationBoxComponent {
|
||||
|
||||
hasPendingBookdropFiles$ = this.bookdropFileService.hasPendingFiles$;
|
||||
|
||||
hasDuplicateFiles$ = this.duplicateFileService.duplicateFiles$.pipe(
|
||||
map(files => files && files.length > 0)
|
||||
);
|
||||
|
||||
hasActiveTasks$ = this.taskEventService.tasks$.pipe(
|
||||
map(tasks => tasks.length > 0)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user