Skip to content

Commit

Permalink
fix: try other date information from fs for Download Date if birtht…
Browse files Browse the repository at this point in the history
…ime is not present
  • Loading branch information
oae committed Feb 1, 2023
1 parent 2e31657 commit d01aa98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,12 @@ function Activity({ data }: { data: ActivityType }) {
export function KaizokuNavbar() {
const { classes } = useStyles();

const historyQuery = trpc.manga.history.useQuery();
const activityQuery = trpc.manga.activity.useQuery();
const historyQuery = trpc.manga.history.useQuery(undefined, {
refetchInterval: 5 * 1000,
});
const activityQuery = trpc.manga.activity.useQuery(undefined, {
refetchInterval: 5 * 1000,
});
const libraryQuery = trpc.library.query.useQuery();

if (!libraryQuery.data) {
Expand Down
12 changes: 11 additions & 1 deletion src/server/utils/mangal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,20 @@ const shouldIncludeFile = (chapterFile: string) => {
export const getChapterFromLocal = async (chapterFile: string) => {
try {
const stat = await fs.stat(chapterFile);
let createdAt = new Date();

if (stat.birthtime.getTime() !== 0) {
createdAt = stat.birthtime;
} else if (stat.ctime.getTime() !== 0) {
createdAt = stat.ctime;
} else if (stat.mtime.getTime() !== 0) {
createdAt = stat.mtime;
}

return {
index: getChapterIndexFromFile(chapterFile)!,
size: stat.size,
createdAt: stat.birthtime,
createdAt,
fileName: path.basename(chapterFile),
};
} catch (err) {
Expand Down

5 comments on commit d01aa98

@flo-dl
Copy link

@flo-dl flo-dl commented on d01aa98 Feb 1, 2023

Choose a reason for hiding this comment

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

Thanks for the quick fix!
Birthtime was indeed missing:

File: [0001]_Chapter_1.cbz
...
Access: 2023-02-01 09:12:58.798215314 +0100
Modify: 2023-02-01 09:12:59.506223609 +0100
Change: 2023-02-01 09:12:59.506223609 +0100
 Birth: -

@flo-dl
Copy link

@flo-dl flo-dl commented on d01aa98 Feb 1, 2023

Choose a reason for hiding this comment

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

EDIT: It is still pulling the v1.5.0 version, so it probably takes some time until it's available. Thanks!

I was a bit too quick. I just upgraded and it didn't fix the issue. Still getting 53 years ago even for newly added mangas.
Should I raise another issue?
download_date_kaizoku_2

@oae
Copy link
Owner Author

@oae oae commented on d01aa98 Feb 1, 2023

Choose a reason for hiding this comment

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

CI is still running. arm builds take forever. So you need to wait a little bit for the v1.5.1 image to be released. Usually takes 1.5 hours

@oae
Copy link
Owner Author

@oae oae commented on d01aa98 Feb 1, 2023

Choose a reason for hiding this comment

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

This change will only affect newly downloaded chapters. If you want existing chapters to be fixed, You need to clear the chapter table from the database and sync chapters.

image

@flo-dl
Copy link

@flo-dl flo-dl commented on d01aa98 Feb 1, 2023

Choose a reason for hiding this comment

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

CI is still running. arm builds take forever. So you need to wait a little bit for the v1.5.1 image to be released. Usually takes 1.5 hours

Ah yeah, saw it on the versions page. It's available now and the dates are showing correctly for newly added media. Thanks!

Please sign in to comment.