Skip to content

feat(web,server): offline/untracked files admin tool - #4447

Merged
danieldietzler merged 14 commits into
mainfrom
feat/file-report
Oct 14, 2023
Merged

danieldietzler merged 14 commits into
mainfrom
feat/file-report

Conversation

@jrasm91

@jrasm91 jrasm91 commented Oct 11, 2023

Copy link
Copy Markdown
Member

WIP report to show offline files as well as untracked files as a report for the admin.

@jrasm91
jrasm91 marked this pull request as draft October 11, 2023 21:49
@vercel

vercel Bot commented Oct 11, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
immich ⬜️ Ignored (Inspect) Visit Preview Oct 13, 2023 7:26pm

@jrasm91 jrasm91 changed the title feat(web,server): offline/extra file admin report feat(web,server): offline/untracked files admin tool Oct 13, 2023
@danieldietzler
danieldietzler force-pushed the feat/file-report branch 2 times, most recently from 73ab86c to bd1fb56 Compare October 13, 2023 18:59

@danieldietzler danieldietzler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Really nice addition and will improve the overall experience with orphaned files and broken references.

@alextran1502 alextran1502 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! Thank you very much for working on this!

}

@AdminRoute()
@Post('file-report/checksum')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using Post here because we need the body?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, we send a list of files to request checksums for

},
},
withDeleted: !!options.trashedBefore,
withDeleted: options.withDeleted ?? !!options.trashedBefore,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a convenient bug fix?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just a new feature so that the report takes soft deleted assets into account

return results;
}

async fixItems(items: FileReportItemDto[]) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not perfoming any file moves operation here, how can we fix the orphaned files in the upload folder??

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we find out where the actual file is stored, we simply update the database to point to it. We decided to fix it on the database side rather than move the file itself.

}
}

const track = (filename: string | null) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain a bit about the purpose of this method?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core of figuring out what files are in the filesystem and not in the database. We start with a list of all the scanned files. Then, as we load assets, people, etc. from the database we're able to mark files as "seen". By removing every file that is referenced by an entity in the database we chip away at the list until only untracked files remain.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method specially, is called on every entity and file path we see in the for loops below.

trashedBefore?: Date;
type?: AssetType;
order?: 'ASC' | 'DESC';
withDeleted?: boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also a convenient bug fix?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously deleted assets were only included in the results when it was used in a specific request for trashed assets. This new option let's me additionally request them for the report query as well


async getInfo(): Promise<ServerInfoResponseDto> {
const libraryBase = this.storageCore.getBaseFolder(StorageFolder.LIBRARY);
const libraryBase = StorageCore.getBaseFolder(StorageFolder.LIBRARY);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! make the method static reduces a lot of code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, figured that was simpler 😁

@danieldietzler
danieldietzler marked this pull request as ready for review October 14, 2023 16:35
@danieldietzler
danieldietzler merged commit d2807b8 into main Oct 14, 2023
@danieldietzler
danieldietzler deleted the feat/file-report branch October 14, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants