Shopify / shopify_theme

A console tool for interacting with Shopify Theme Assets.
http://shopify.github.io/shopify_theme
MIT License
645 stars 135 forks source link

Updating files when running `watch` task occasionally removes files. #212

Open samrap opened 8 years ago

samrap commented 8 years ago

I have been having this error since I started using this tool about a week ago, but it doesn't seem like anyone else is or has, so maybe I'm doing something wrong.

When I run the theme watch task, I make changes to a certain template file, save it, and the changes are then reflected on the development server. Great! However, about one in ten times, this tool will perform an update and remove operation on the file (on the server) and I reload the page and get a "template not found error". I typically have to resave the file a few times for it to actually successfully upload. At this point, I can make a few more changes until the issue repeats itself.

Screenshot

Any ideas what's going on here? It may not sound like a big deal, but it's a pretty big hinderance on my workflow.

SB3K commented 8 years ago

I am seeing this behaviour too. If I make a change to a file it will 'remove'. If I change the file again, it will update.

samrap commented 8 years ago

Sometimes it takes multiple times for it to update. There a few times today I had to hit save up to 5 times in order for it to update instead of remove.

Cam commented 8 years ago

Me too. I find this is happening with most stores most of the time.

samrap commented 8 years ago

After some digging I found out that in my case, it has to do with the way the Sublime Text editor handles file saving (atomic save). There's some more info here but setting atomic save to false in Sublime Text fixed this issue for me.

Essentially what is going on is that the tmp files the editor creates get swapped with the actual file you're editing. Apparently this Shopify tool picks up on those files and gets confused (since they are created/deleted/replacing content/etc) and sometimes sends the wrong operation to the server.

It would be nice if the developers could update to ignore all .subl.tmp files. Something like:

(?:.subl)(.*)(?:.tmp)

Filename format is as follows: .sublc92.tmp, where c92 is a unique hash.

SB3K commented 8 years ago

Interesting @samrap - I just switched to Visual Studio Code from Sublime and it works fine now.

samrap commented 8 years ago

@SB3K You can also edit your sublime user preferences and set "atomic_save": false,. No need to switch IDEs! ;)

samrap commented 8 years ago

Adding .subl* to ignore_files configuration does not work either. It seems that ignore_files doesn't actually ignore files in the sense of pretending like they aren't there, it just simply doesn't upload them.