adobe-photoshop / generator-assets

Generator Plug-in for Adobe Photoshop CC that helps users export image assets
MIT License
494 stars 87 forks source link

Tech Doc candidate: Spec Question: Can I get a warning when assets will be overridden? #55

Closed itoda closed 11 years ago

itoda commented 11 years ago

Situations like below

I heard this question from prerelease user and Japanese testers. QE perspective, this is a reasonable request.

DennisKehrig commented 11 years ago

Oh, interesting. While no two files can have the same file name, two unsaved documents can indeed have the same name. Hmmm. Maybe we should use the document ID as a suffix for the folder name in these cases after all?

@joelrbrandt @timriot Your takes?

@itoda Though I'm not sure why I would need to duplicate any layers (and change the tags in the duplicate) to end up in this situation. All it takes is two unsaved documents with the same name and at least one layer per document that exports the same asset.

Another good reason not to move the entire -assets folder on save, I guess :)

joelrbrandt commented 11 years ago

My original idea was to only allow Web Asset generation when the document was already saved. (I.e. you can't even turn it on for unsaved documents.) The challenge with this is that it's tough to figure out how to message to the user why they can't use a feature. So, that approach is probably a non-starter.

Anyway, my take is that if the user gets into this situation, then they're TRYING to get into this situation. So, I don't think it's necessary to warn the user. I don't personally believe we need to do anything differently than we are now. (I.e. the most recently edited layer will be the one that has an asset in the "assets" folder).

However, @timriot should be the final decider.

DennisKehrig commented 11 years ago

Well, Photoshop actively prevents uses from creating two documents with the same path: If you have the other document open, you cannot save at the same location. If the other document is not open, you'll overwrite the file.

But Photoshop does not prevent you from creating two unsaved documents with the same name. And that usually does not produce conflicts, except now, with Generator. So I'm hesitant to be the one who breaks that, especially since the folder name doesn't matter that much for unsaved files, anyway.

@timriot Is there a way to change a document name other than saving it?

itoda commented 11 years ago

Maybe this is same type of question as Barry (He added his request in the Photoshop bug board in Trello). Can we just give them a warning ? I believe this is the Photoshop way to take care of our user.

DennisKehrig commented 11 years ago

What should be the circumstances, though? That needs to be clearly defined. We should be able to say that two documents with the same name are open, for instance. If the user activates Web Assets for another unsaved file with the same name, we could warn them, and even just ignore that click. But if the user then closes the first file, and enables asset generation for the second, they would already end up overwriting the files from the first one. This tiny little warning requires us to do a lot of nasty tracking if we make it more specific.

timriot commented 11 years ago

NO WARNING(S). I agree with Joel that if someone is going through the effort of creating two unsaved documents, then enable Generator for both, they are trying to do something. I would say that we should create the default assets directory that we create for an unsaved document, then create another with a "-1" at end, then a "-2" and so on, similar to how Finder works. In all likelihood if the person is doing real work, they will decide to save the files, which will remove these little suckers. Let me know if you have more questions.

DennisKehrig commented 11 years ago

@itoda I'll leave it up to you to close this, unless you have further objections?

itoda commented 11 years ago

First of all, these are all different cases and not a reproduce step. I listed 4 different cases. Sorry for the confusion. I should have answered Dennis question first. Unsaved doc, I kind of understood engineering effort. How about other cases like

DennisKehrig commented 11 years ago

There's a rule called garbage in -> garbage out. If the user uses the same file name twice, they made a mistake that they should fix. It would be nice for the software to gently nudge them so they notice it more easily, but investing more effort seems misplaced to me.

If we want to support duplicate layer names anyway, this results in a split between the user input and the effective file names. This should be as deterministic as possible, so we need a canonical order in which the layers are handled to produce the effective file names. Assume the following input scenario:

What should the output be?

Flattened list approach:

Flattened list, keep first intact:

Level approach:

Level approach, keep first intact:

Hierarchy approach:

The hierarchy approach still contains ambiguity. Assume the following input scenario:

One approach could produce:

Another could produce:

Depending on the order of precedence (list bias or level bias).

All this needs to be properly specified. And then we need to keep track of

So this is all very messy.

DennisKehrig commented 11 years ago

About "User generate assets with png first then change to jpg? Same effort?" - I'm not sure I understand. If the question is what the effort would be to not delete an output file when changing only the extension, then we might need to consider more than the simple case "foo.jpg" -> "foo.png".

What if the user changes "foo.jpg" into "foo.png, bar.jpg"

Or "foo.jpg" into "bar.jpg, foo.png"

Did the user rename the name or the extension?

How about this one: "foo.jpg, bar.png" into "foo.png, bar.jpg"

We could compare every component of the original name ("foo.jpg", "bar.png") with every component of the new name ("foo.png", "bar.jpg") and see if everything but the extension is the same for any such pair. If so, we do not delete the previously generated file (in the last case resulting in four files named "foo.jpg", "foo.png", "bar.jpg", "bar.png"). We would not remember this information, though. This means that if later the user decided to rename another layer to "foo.jpg", the existing "foo.jpg" file is considered the same as if created there manually by the user (it would be overwritten).

timriot commented 11 years ago

I think we should punt on dealing with duplicate layer names. After all, the user must specifically name the layers. The content being tagged will inform the name, which should self enforce unique names. Layer filtering should also help resolve any issues.

WRT to changing a layer name from foo.jpg to foo.png, this is a user statement that foo.jpg should be removed and foo.png should be created. No fuss, just get rid of the previous asset that was tagged and create the new one.

DennisKehrig commented 11 years ago

@timriot If I understand you correctly, this ticket can be closed as wontfix, yes?

timriot commented 11 years ago

Okay to close, so long as changing a layer name works as I describe. =]

DennisKehrig commented 11 years ago

With the exception of #29, I think that is so. :)