-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow non-read-only external libraries that support asset deletion #8943
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,9 @@ export class UpdateLibraryDto { | |
@ValidateBoolean({ optional: true }) | ||
isVisible?: boolean; | ||
|
||
@ValidateBoolean({ optional: true }) | ||
isReadOnly?: boolean; | ||
|
||
@Optional() | ||
@IsString({ each: true }) | ||
@IsNotEmpty({ each: true }) | ||
|
@@ -128,6 +131,8 @@ export class LibraryResponseDto { | |
createdAt!: Date; | ||
updatedAt!: Date; | ||
refreshedAt!: Date | null; | ||
|
||
isReadOnly!: boolean | null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't nullable. |
||
} | ||
|
||
export class LibraryStatsResponseDto { | ||
|
@@ -160,5 +165,6 @@ export function mapLibrary(entity: LibraryEntity): LibraryResponseDto { | |
assetCount, | ||
importPaths: entity.importPaths, | ||
exclusionPatterns: entity.exclusionPatterns, | ||
isReadOnly: entity.isReadOnly, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,9 @@ export class LibraryEntity { | |
|
||
@Column({ type: 'boolean', default: true }) | ||
isVisible!: boolean; | ||
|
||
@Column({ type: 'boolean', nullable: true }) | ||
isReadOnly!: boolean | null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be nullable and should default to true |
||
} | ||
|
||
export enum LibraryType { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class AddLibraryReadOnly1712293452361 implements MigrationInterface { | ||
name = 'AddLibraryReadOnly1712293452361' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "libraries" ADD "isReadOnly" boolean`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "libraries" DROP COLUMN "isReadOnly"`); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -372,8 +372,10 @@ export class AssetService { | |
return JobStatus.FAILED; | ||
} | ||
|
||
// Ignore requests that are not from external library job but is for an external asset | ||
if (!fromExternal && (!asset.library || asset.library.type === LibraryType.EXTERNAL)) { | ||
// Ignore requests that are not from external library job but is for an external read-only asset | ||
const isReadOnlyLibrary = !asset.library || asset.library.isReadOnly || | ||
(asset.library.isReadOnly === null && asset.library.type === LibraryType.EXTERNAL); | ||
if (!fromExternal && isReadOnlyLibrary) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should just check if from external and the asset is read only and skip if so. No reason to make it complicated. |
||
return JobStatus.SKIPPED; | ||
} | ||
|
||
|
@@ -406,7 +408,7 @@ export class AssetService { | |
} | ||
|
||
const files = [asset.thumbnailPath, asset.previewPath, asset.encodedVideoPath]; | ||
if (!(asset.isExternal || asset.isReadOnly)) { | ||
if (!isReadOnlyLibrary) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If asset isn't readonly |
||
files.push(asset.sidecarPath, asset.originalPath); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this shouldn't be nullable either