Skip to content

Conversation

@DavidBurela
Copy link
Contributor

@DavidBurela DavidBurela commented May 17, 2020

This PR resolves #435

A small change to put downloaded assets into /year/month subfolder. This is done by using the date of the post as the subfolder in the assets folder. This keeps the assets chronologically with the post, and reduces clashes as this is the same as how Wordpress store their files.

Before:
When I ran the import tool on my blog, I had 350 clashes of images being overwritten.

After:
I successfully ran this on my blog https://DavidBurela.wordpress.com, which has 13 years, 230 posts. I only ended up with 5 clashes (which was due to me referencing images in other posts).

Note: I have never coded in Ruby before. I naively implemented it with the smallest number of changes that I could to reduce bugs.

Copy link
Member

@ashmaroli ashmaroli left a comment

Choose a reason for hiding this comment

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

Some minor edits required..

@DavidBurela
Copy link
Contributor Author

Pulled date subfolder logic earlier in execution chain. This keeps method signature intact. Guarded it with an if statement, so it should also be safer than the original.

Tested it on a fresh import of 161 posts with 837 images.

@DavidBurela
Copy link
Contributor Author

Thanks for your patience on this PR. As I mentioned, I've never used Ruby. So your assistance has been appreciated.

@ashmaroli
Copy link
Member

As I mentioned, I've never used Ruby.

Yes, that's the reason I walked you through this.

I did not merge this yet because I'm not sure if everyone would want their assets put into this particular subdir path.

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

I think this is a reasonable addition for new imports! I like that there is some date information preserved, and that it will be familiar for people from WordPress, since this is how WordPress organizes images too.

@ashmaroli
Copy link
Member

@jekyllbot: merge +fix

@jekyllbot jekyllbot merged commit b72aeae into jekyll:master May 21, 2020
jekyllbot added a commit that referenced this pull request May 21, 2020
@ashmaroli
Copy link
Member

Thank you @DavidBurela

@jekyll jekyll locked and limited conversation to collaborators Jul 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WordpressDotCom importer overwrites assets

4 participants