-
-
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
Conversation
I think the most natural change of this feature is to let the user know they can mount the library with |
Hm. That would mean checking mount info (only on boot? on rescan too?) and updating the flags based on that. Seems nice in terms of not adding any admin UI. I'm slightly worried about potential surprising behavior (e.g. adding a writable mount, possibly for multiple libraries inside of it, and adding libraries in the admin interface, not expecting them to be automatically writable) but on the other hand "it's a purely outside configured sysadmin level decision" does feel nice in a way. Not sure we'd actually avoid the flag on the library, even if it would get set automatically based on the mount: it would definitely make sense to show in the admin interface whether it is writable, and have that fully consistent with what we've set for the assets… |
@etnoy I am pretty sure |
I am thinking more of, if the user know that they use the |
I would recommend keeping the per asset flags. Otherwise it will probably be a nightmare trying to load in the property everywhere it needs to be used. If a library is marked as read only, it seems easy enough to do a bulk asset update |
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.
This seems fine, but should be simplified. Furthermore, when a library is updated and readonly changes we should SQL update the affected assets.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't nullable.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be nullable and should default to true
// 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 comment
The 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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
If asset isn't readonly
@@ -193,7 +193,7 @@ | |||
{/if} | |||
|
|||
{#if isOwner} | |||
{#if !asset.isReadOnly || !asset.isExternal} | |||
{#if !asset.isReadOnly || !asset.isExternal || (true /* XXX */)} |
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.
Just change this to asset not read only
const prevValue = library.isReadOnly == null ? (library.type === LibraryType.External) : library.isReadOnly; | ||
|
||
try { | ||
await updateLibrary({ id: library.id, updateLibraryDto: { ...library, isReadOnly: !prevValue } }); |
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.
Please don't send the whole dto. Just send the read only setting.
@@ -397,6 +410,12 @@ | |||
<Portal target="body"> | |||
<ContextMenu {...contextMenuPosition} on:outclick={() => onMenuExit()}> | |||
<MenuOption on:click={() => onRenameClicked()} text={`Rename`} /> | |||
<MenuOption | |||
on:click={() => onToggleReadOnlyClicked()} | |||
text={(selectedLibrary?.isReadOnly || |
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.
This should not be nullable
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.
we could probably change the {#if showContextMenu}
above to {#if showContextMenu && selectedLibrary}
to simplify all the accesses to selectedLibrary
within
@@ -8778,6 +8778,10 @@ | |||
}, | |||
"type": "array" | |||
}, | |||
"isReadOnly": { | |||
"nullable": true, |
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
Hey, thanks for working on this and sorry for the confusion/back and forth around this topic. Internally we have had a lot of discussions about the direction we want to take external libraries. Long story short, we decided to go ahead with the implementation laid out in #9235. |
Related: #5449 #8438
Sponsored by: @benmccann
This is an attempt at switching from hardcoded "external means cannot delete" to an explicit
isReadOnly
flag for libraries. (Not fully polished change yet, hence draft)The per-asset
isExternal
andisReadOnly
flags being stored in the database is making this difficult… I guess just using them and updating them while the library's read-onliness changes would be significantly easier than removing them and making everywhere query the library flags, but I'm looking for feedback re: the right way to do this.