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

Determine whether to add a project/ root dir to export zip #889

Closed
humphd opened this Issue Aug 19, 2015 · 17 comments

Comments

Projects
7 participants
@humphd
Member

humphd commented Aug 19, 2015

This is something @Pomax raised, and I've been pondering it ever since. When you export your project as a .zip file, we currently take everything in your project, and add it to a project.zip file, with things rooted in project/*. This means that index.html in your project becomes project/index.html in the zip file. It's generally seen as bad form to have archive files expand directly into the current directory, since you end up littering your current working dir with a bunch of files: most people root their archive with some folder to avoid this mess.

But consider the case of someone exporting a project, emailing it to a friend, and then that friend dragging it into Thimble. It will work, but they will end up with a project/ subdir with all the files in that. Should we try and preempt this, and add a special case for project/* and strip it? Or should I go against good practice and throw away project/ altogether, and just archive exactly what's in your project?

cc @simonwex, @flukeout

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Nov 13, 2015

Member

@flukeout suggests using thimble-project/* and then watch for this and nuke it when we import.

Member

humphd commented Nov 13, 2015

@flukeout suggests using thimble-project/* and then watch for this and nuke it when we import.

@humphd humphd self-assigned this Nov 13, 2015

@humphd humphd added this to the Final stride milestone Nov 13, 2015

@gideonthomas gideonthomas added P3 and removed feedback labels Jan 6, 2016

@gideonthomas gideonthomas removed this from the Final stride milestone Jan 19, 2016

@gideonthomas gideonthomas removed P3 labels Oct 31, 2016

@flukeout

This comment has been minimized.

Show comment
Hide comment
@flukeout

flukeout Jan 16, 2017

Contributor

@humphd I think exporting / importing zip files is pretty fringe so I'm happy to close this unless we run into it again or hear about it from users.

Contributor

flukeout commented Jan 16, 2017

@humphd I think exporting / importing zip files is pretty fringe so I'm happy to close this unless we run into it again or hear about it from users.

@Pomax

This comment has been minimized.

Show comment
Hide comment
@Pomax

Pomax Jan 28, 2017

Contributor

Hello I am a user =)

Being able to drag my code into Thimble for immediate editing and then getting it back out with an export is actually really nice. Rather than close, I'd say "let's go with thimble-project and if an imported zip only contains that dir at the top level, move everything up one level".

It's a nice feature to have, an interesting feature to work on for contributors, and opens up thimble as a roundtripping workflow tool that it currently simple cannot be used for.

Contributor

Pomax commented Jan 28, 2017

Hello I am a user =)

Being able to drag my code into Thimble for immediate editing and then getting it back out with an export is actually really nice. Rather than close, I'd say "let's go with thimble-project and if an imported zip only contains that dir at the top level, move everything up one level".

It's a nice feature to have, an interesting feature to work on for contributors, and opens up thimble as a roundtripping workflow tool that it currently simple cannot be used for.

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Jan 28, 2017

Member

The code for this is in here https://github.com/mozilla/brackets/blob/master/src/filesystem/impls/filer/ArchiveUtils.js. It would be pretty easy to change.

Member

humphd commented Jan 28, 2017

The code for this is in here https://github.com/mozilla/brackets/blob/master/src/filesystem/impls/filer/ArchiveUtils.js. It would be pretty easy to change.

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Feb 16, 2017

Member

I've suggested that @Riyuzakii work on this, and I'll mentor.

Member

humphd commented Feb 16, 2017

I've suggested that @Riyuzakii work on this, and I'll mentor.

@Riyuzakii

This comment has been minimized.

Show comment
Hide comment
@Riyuzakii

Riyuzakii Feb 17, 2017

@humphd What are the things that i need to know to fix this bug , because i saw the code and i am quite confused.

Riyuzakii commented Feb 17, 2017

@humphd What are the things that i need to know to fix this bug , because i saw the code and i am quite confused.

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Feb 17, 2017

Member

@Riyuzakii we have code that allows a user to a) download a project.zip archive file; and b) drag-and-drop a *.zip file into the file tree, see:

The code that does this automatically takes your files, and prepends a project/* parent directory to everything:

https://github.com/mozilla/brackets/blob/master/src/filesystem/impls/filer/ArchiveUtils.js#L153-L156

We do this because it's considered good form to always have a zip file expand into a directory vs. into the current directory (it makes it easier to delete or move the files afterward).

In the case that you export a project.zip from Thimble on one computer, then on another computer want to drag-and-drop that project.zip back into Thimble, it would be nice if we ignored the project/* parent folder and just extracted the files directly into the current directory--otherwise you have to do everything inside a project/ dir now, and if you exported/imported again, you'd have project/project/* etc.

When we do the extraction, we first begin by scanning all the files/folders in the zip archive and build a list of filenames:

https://github.com/mozilla/brackets/blob/master/src/filesystem/impls/filer/ArchiveUtils.js#L82-L93

Right here, we could do a bit more work to look for files that begin with project/ and then strip that so that a file project/index.html becomes just index.html.

Let me know if this makes sense or not, and if you have more questions. You can also chat with the developers by using Mozilla's Thimble channel on their Mattermost server, see https://github.com/mozilla/thimble.mozilla.org#contact-us.

Member

humphd commented Feb 17, 2017

@Riyuzakii we have code that allows a user to a) download a project.zip archive file; and b) drag-and-drop a *.zip file into the file tree, see:

The code that does this automatically takes your files, and prepends a project/* parent directory to everything:

https://github.com/mozilla/brackets/blob/master/src/filesystem/impls/filer/ArchiveUtils.js#L153-L156

We do this because it's considered good form to always have a zip file expand into a directory vs. into the current directory (it makes it easier to delete or move the files afterward).

In the case that you export a project.zip from Thimble on one computer, then on another computer want to drag-and-drop that project.zip back into Thimble, it would be nice if we ignored the project/* parent folder and just extracted the files directly into the current directory--otherwise you have to do everything inside a project/ dir now, and if you exported/imported again, you'd have project/project/* etc.

When we do the extraction, we first begin by scanning all the files/folders in the zip archive and build a list of filenames:

https://github.com/mozilla/brackets/blob/master/src/filesystem/impls/filer/ArchiveUtils.js#L82-L93

Right here, we could do a bit more work to look for files that begin with project/ and then strip that so that a file project/index.html becomes just index.html.

Let me know if this makes sense or not, and if you have more questions. You can also chat with the developers by using Mozilla's Thimble channel on their Mattermost server, see https://github.com/mozilla/thimble.mozilla.org#contact-us.

@Riyuzakii

This comment has been minimized.

Show comment
Hide comment
@Riyuzakii

Riyuzakii Feb 18, 2017

@humphd no it didn't make much sense but i think that's because i know only basic level javascript.

Riyuzakii commented Feb 18, 2017

@humphd no it didn't make much sense but i think that's because i know only basic level javascript.

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Feb 18, 2017

Member

@Riyuzakii OK, got it. Maybe this isn't a good first project then? We use a lot of JS, and in some complex ways. If you decide you want to try things, we'll try to help you here. If it's too much, no problem.

Member

humphd commented Feb 18, 2017

@Riyuzakii OK, got it. Maybe this isn't a good first project then? We use a lot of JS, and in some complex ways. If you decide you want to try things, we'll try to help you here. If it's too much, no problem.

@Riyuzakii

This comment has been minimized.

Show comment
Hide comment
@Riyuzakii

Riyuzakii Feb 18, 2017

@humphd I definitely want to do this and i have even started learning JS further.

Riyuzakii commented Feb 18, 2017

@humphd I definitely want to do this and i have even started learning JS further.

@gideonthomas gideonthomas moved this from TODO to In Progress in Technical Debt Feb 20, 2017

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Mar 2, 2017

Member

@Riyuzakii how is this going? Do you need some help?

Member

humphd commented Mar 2, 2017

@Riyuzakii how is this going? Do you need some help?

@Riyuzakii

This comment has been minimized.

Show comment
Hide comment
@Riyuzakii

Riyuzakii Mar 2, 2017

@humphd I have been a bit busy with my mid-semester exams for the past week and they end on sunday so i'll restart then.

Riyuzakii commented Mar 2, 2017

@humphd I have been a bit busy with my mid-semester exams for the past week and they end on sunday so i'll restart then.

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Mar 20, 2017

Member

@Riyuzakii I'm going to put this bug back into the general pool of available bugs. If you decide you want to work on something, let me know and I'll try to find you another one.

Member

humphd commented Mar 20, 2017

@Riyuzakii I'm going to put this bug back into the general pool of available bugs. If you decide you want to work on something, let me know and I'll try to find you another one.

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Mar 23, 2017

Member

NOTE: I'm refactoring the code this will need to change, so be aware of mozilla/brackets#659

Member

humphd commented Mar 23, 2017

NOTE: I'm refactoring the code this will need to change, so be aware of mozilla/brackets#659

@sdalmeida

This comment has been minimized.

Show comment
Hide comment
@sdalmeida

sdalmeida Apr 5, 2017

Contributor

Any luck I can tackle on this bug? I worked on this file while fixing issue mozilla/brackets#596 so I'm familiar with the code. Or should I wait for your PR?

Contributor

sdalmeida commented Apr 5, 2017

Any luck I can tackle on this bug? I worked on this file while fixing issue mozilla/brackets#596 so I'm familiar with the code. Or should I wait for your PR?

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd Apr 5, 2017

Member

@Simon66 go for it. NOTE: I'm changing this code a lot in mozilla/brackets#659 which should hopefully land soon. I'm just waiting on mozilla/brackets#635 to merge first.

Member

humphd commented Apr 5, 2017

@Simon66 go for it. NOTE: I'm changing this code a lot in mozilla/brackets#659 which should hopefully land soon. I'm just waiting on mozilla/brackets#635 to merge first.

@humphd

This comment has been minimized.

Show comment
Hide comment
@humphd

humphd May 8, 2017

Member

I've landed #659 so, feel free to rebase and finish this.

Member

humphd commented May 8, 2017

I've landed #659 so, feel free to rebase and finish this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment