Skip to content
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

fix: infofile add extension name first #1203

Merged
merged 1 commit into from
Dec 3, 2022

Conversation

cokemine
Copy link
Contributor

@cokemine cokemine commented Dec 2, 2022

This PR should fix: #982
I can confirm this issue both happens on Linux and Windows.

The arg of PixivHelper.sanitize_filename() should have a extname for info file otherwise trailing dots and spaces from the title will be removed, which is not as expected.

@Nandaka Nandaka merged commit d233add into Nandaka:master Dec 3, 2022
@cokemine cokemine deleted the fix/infofile branch December 3, 2022 02:15
@biggestsonicfan
Copy link
Contributor

I'm not too familiar with what's happening in this exact code, but is there a reason pathlib isn't being used to handle this?

@NewUserHa
Copy link
Contributor

indeed should use PurePath.stem to trim the last dot in the filename to avoid more issues.

@cokemine
Copy link
Contributor Author

cokemine commented Dec 3, 2022

indeed should use PurePath.stem to trim the last dot in the filename to avoid more issues.

I wonder why we have to trim last dots ? All info file should have a ext name .txt or .json
....txt both valid on Windows and Linux

@NewUserHa
Copy link
Contributor

The arg of PixivHelper.sanitize_filename() should have a extname for info file otherwise trailing dots and spaces from the title will be removed, which is not as expected.

Isn't the PR trying to trim the last dot of the filename without the suffix?

I currently didn't encounter any issues with the default filename template. How can [:-8] be right for the default filename template?

@cokemine
Copy link
Contributor Author

cokemine commented Dec 3, 2022

The arg of PixivHelper.sanitize_filename() should have a extname for info file otherwise trailing dots and spaces from the title will be removed, which is not as expected.

Isn't the PR trying to trim the last dot of the filename without the suffix?

I currently didn't encounter any issues with the default filename template. How can [:-8] be right for the default filename template?

I don't think it's needed to trim the suffix dots if the file has an explicit extension name (.txt or .json)

Before this PR, . from image title are trimed. This is because it is passed into PixivHelper.sanitize_filename() without the extension.(info file) I added a fake extension .infoext to circumvent this, and then write the file with the correct extension.

But for image file, The argument of PixivHelper.sanitize_filename() containing the corrent extension name of the image, so . won't be trimed

I think PurePath.stem has the same effect, but the fake extension I set is a fixed length, so I didn't use it

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.

Trailing . left on image name but not info file.
4 participants