Skip to content

prefix file names#919

Merged
killergerbah merged 1 commit intomainfrom
fix/prefix-file-names
Mar 5, 2026
Merged

prefix file names#919
killergerbah merged 1 commit intomainfrom
fix/prefix-file-names

Conversation

@mwojick
Copy link
Copy Markdown
Collaborator

@mwojick mwojick commented Mar 3, 2026

closes #917

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying asbplayer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 657ea9f
Status: ✅  Deploy successful!
Preview URL: https://bb82afb2.asbplayer.pages.dev
Branch Preview URL: https://fix-prefix-file-names.asbplayer.pages.dev

View logs

name = sanitize(name, { replacement: replacement });
// Prefix to allow filtering by asbplayer created files,
// and to prevent Anki from skipping cleanup of files that start with an underscore.
return 'asbp_' + name;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Only reservation with this change, is that IIRC there was a file length limit on Android that caused me to make the file names really short, like <= 32 characters. With this change it might be possible to go over that limit. One way to work around this would be to add the asbp_ prefix in makeFileName in audio-clip.ts and image.ts instead.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Or maybe reducing maxPrefixLEngth in those files by 5

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Does the problem on Android have to do with creating cards on Android? Or just viewing them on AnkiDroid? Seems like viewing is fine for me, but I've never tried making them on Android. Either way I think we would already have an issue if 32 was the limit since you have the prefix (24) plus the timestamp + random string (18)

Copy link
Copy Markdown
Collaborator Author

@mwojick mwojick Mar 4, 2026

Choose a reason for hiding this comment

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

Actually I just tried loading it into Firefox Nightly on Android using web-ext (such a pain to setup) with Ankiconnect Android, and the audio file seems fine too (img still doesn't get captured on Android FF). Though there's a random number at the end instead of the random string. Does Ankiconnect create that and is that related to the issue?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Does the problem on Android have to do with creating cards on Android? Or just viewing them on AnkiDroid?

It was the former

Either way I think we would already have an issue if 32 was the limit since you have the prefix (24) plus the timestamp + random string (18)

Yeah tbh I don't remember what the actual limit was. It's possible I chose a very small number just to be very safe.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Though there's a random number at the end instead of the random string. Does Ankiconnect create that and is that related to the issue?

Hmm yeah must be AnkiConnect by process of elimination. I suppose that would increase the filename length but if it's working for you I guess we're fine. A limit in the 40s feels extraordinarily small for an OS.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

From Googling, the smallest number I could fine was 50. Does the filename you observed in AniiConnect less than 50?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With the new prefix I'm getting in total between like 56-58 (excluding file ext) depending on the length of the timestamp. The number at the end (idk if it's a random num or what) is around 20 by itself. I searched around as well and heard that the limit can be between 63-255 depending on encoding but who knows. Maybe it was less on older Android versions too. Either way I'll leave it up to you

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Sounds like we were already above 50 so the limit being more like 63 seems more plausible. Let's just yolo it and we can always lower it back down if it's a problem.

@killergerbah killergerbah merged commit 5226a95 into main Mar 5, 2026
2 checks passed
@killergerbah killergerbah deleted the fix/prefix-file-names branch March 5, 2026 11:49
@killergerbah killergerbah added this to the Extension v1.15.0 milestone Mar 5, 2026
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.

Exported files need underscores to be removed from the front of the filename

2 participants