You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
transfer_summarizer produces a warning for files of size zero:
Error calculating percentage 0/0, is foo empty?
My feeling is that this warning is excessive as it implies that a file of size 0 is some kind of problem. Sshkit's output would be a bit less noisy if it just special-cased the percentage for files of size zero as 100%.
I'm curious, what is your use-case for uploading a zero-byte file? I think using touch would be preferable in this case, but I'd like to understand why you are running into this.
There is a convention with git of placing a zero byte file in a directory in order to ensure that the directory exists when there is no other version controlled content in it. It is just these harmless files (usually .gitkeep) that are occasionally here and there in my project that end up causing warnings during upload with sshkit.
I see. I hesitate fixing this "bug" because an argument could be made that uploading an empty file is a mistake that deserves a warning.
It sounds like you are iterating through files in your project and uploading them using upload!. Could you work around the warning by testing each file with File.empty? before uploading it?
Reasonable, but it leads me to consider another case:
I'm uploading a directory of css files to my website that were generated with Sass. Since this directory contains only generated files, that is why I had an empty .gitkeep file in it. However, generated css files could sometimes be empty themselves, and in such cases, I would still want to upload those files - they are empty, but they are valid css files, and I would not want requests for them to 404.
Also unless there is something really weird going on, the only circumstance that can trigger this warning is a division by zero. The warning is basically reporting a divide-by-zero error, but the division operation isn't the important concern of transfer_summarizer - the transfer status is. The division operation gets us the transfer status, but must be interpreted in the case of a divisor of zero. In that case, the transfer status must be 100%.
Well I do love to go down little philosophical rabbit holes like this, and hope I haven't been a bother. I'll go along with whatever you decide. Cheers :-)
Uploading empty files sounds like a bad idea, and I don't buy the
.gitignore reasoning, Ruby's dir goobbing should be used to select correct
files to sync imho.
Disabling a useful warning that would normally indicate an error condition
(badly parsed tempates, etc) in order to get SCM artifacts onto the server
strikes me as a step backwards, or at least sideways into a less safe tool.
Am 22.02.2017 20:12 schrieb "Matt Brictson" <notifications@github.com>:
@retroj For the css case specifically, it feels like making a user download an empty css file (and possibly block the rendering of the web page until it finishes) is something we should try to avoid. Is dealing with empty SASS generated css files a common problem?
@robd I think that the typical case for an empty css file would be while developing a site, one might put files in place before writing their content. I don't think that is a problem or not-a-problem, but the question is, what is the right thing to do for an empty file when there is one, be it css or something else? Serve the empty file or 404? Those two responses have two different meanings, and could also trigger different web server behaviors in some circumstances. I lean toward treating empty files as ordinary, not warranting of any special callout.
At the risk of being long-winded, if I could resummarize: sshkit does currently upload empty files when told to - that is the correct, expected behavior. The questions are, 1) should capistrano users avoid uploading empty files to their websites, and 2) should sshkit's progress indicator report a division-by-zero warning when they do? I would answer, users should upload whatever they want, and there is no special reason for the progress indicator to report an internal detail like the division by zero that occurred when calculating the progress of a size 0 file because the progress of such a file is known to be 100%.
@retroj Ah OK I see - I hadn't thought of that case. For me it still feels desirable to warn for the empty file since this would only be a temporary situation while the site is developed. If it turns out that I put some css in the file, then the warning goes away, if I don't use it then it's a reminder to delete it again, which personally I would find helpful.
In the more general case I tend to agree with Lee that an empty file is normally some kind of problem and probably not what the user wanted to upload. But I would be interested in understanding if there are people who are seeing this noise a lot - I can see that it's annoying to have the logs polluted. Are there any other cases apart from .gitkeep and placeholder css files which you are seeing?
One improvement would be to change the implementation to check explicitly for the empty case and warn with a clearer error in the empty file case File is empty rather than lumping it in with the normal nan error, and then we could remove the is foo empty? in the error case.
Activity
mattbrictson commentedon Feb 21, 2017
Thanks for the suggestion!
I'm curious, what is your use-case for uploading a zero-byte file? I think using
touchwould be preferable in this case, but I'd like to understand why you are running into this.retroj commentedon Feb 21, 2017
There is a convention with git of placing a zero byte file in a directory in order to ensure that the directory exists when there is no other version controlled content in it. It is just these harmless files (usually .gitkeep) that are occasionally here and there in my project that end up causing warnings during upload with sshkit.
mattbrictson commentedon Feb 22, 2017
I see. I hesitate fixing this "bug" because an argument could be made that uploading an empty file is a mistake that deserves a warning.
It sounds like you are iterating through files in your project and uploading them using
upload!. Could you work around the warning by testing each file withFile.empty?before uploading it?retroj commentedon Feb 22, 2017
Reasonable, but it leads me to consider another case:
I'm uploading a directory of css files to my website that were generated with Sass. Since this directory contains only generated files, that is why I had an empty .gitkeep file in it. However, generated css files could sometimes be empty themselves, and in such cases, I would still want to upload those files - they are empty, but they are valid css files, and I would not want requests for them to 404.
Also unless there is something really weird going on, the only circumstance that can trigger this warning is a division by zero. The warning is basically reporting a divide-by-zero error, but the division operation isn't the important concern of transfer_summarizer - the transfer status is. The division operation gets us the transfer status, but must be interpreted in the case of a divisor of zero. In that case, the transfer status must be 100%.
Well I do love to go down little philosophical rabbit holes like this, and hope I haven't been a bother. I'll go along with whatever you decide. Cheers :-)
mattbrictson commentedon Feb 22, 2017
@leehambley any objections to removing the upload warning for empty files? It looks like you were last to touch this code in cbc9064
leehambley commentedon Feb 22, 2017
retroj commentedon Feb 22, 2017
Hello Lee,
Do you have thoughts on the use case of empty css files? Thank you,
robd commentedon Feb 23, 2017
@retroj For the css case specifically, it feels like making a user download an empty css file (and possibly block the rendering of the web page until it finishes) is something we should try to avoid. Is dealing with empty SASS generated css files a common problem?
retroj commentedon Feb 23, 2017
@robd I think that the typical case for an empty css file would be while developing a site, one might put files in place before writing their content. I don't think that is a problem or not-a-problem, but the question is, what is the right thing to do for an empty file when there is one, be it css or something else? Serve the empty file or 404? Those two responses have two different meanings, and could also trigger different web server behaviors in some circumstances. I lean toward treating empty files as ordinary, not warranting of any special callout.
At the risk of being long-winded, if I could resummarize: sshkit does currently upload empty files when told to - that is the correct, expected behavior. The questions are, 1) should capistrano users avoid uploading empty files to their websites, and 2) should sshkit's progress indicator report a division-by-zero warning when they do? I would answer, users should upload whatever they want, and there is no special reason for the progress indicator to report an internal detail like the division by zero that occurred when calculating the progress of a size 0 file because the progress of such a file is known to be 100%.
robd commentedon Feb 23, 2017
@retroj Ah OK I see - I hadn't thought of that case. For me it still feels desirable to warn for the empty file since this would only be a temporary situation while the site is developed. If it turns out that I put some css in the file, then the warning goes away, if I don't use it then it's a reminder to delete it again, which personally I would find helpful.
In the more general case I tend to agree with Lee that an empty file is normally some kind of problem and probably not what the user wanted to upload. But I would be interested in understanding if there are people who are seeing this noise a lot - I can see that it's annoying to have the logs polluted. Are there any other cases apart from .gitkeep and placeholder css files which you are seeing?
One improvement would be to change the implementation to check explicitly for the empty case and warn with a clearer error in the empty file case
File is emptyrather than lumping it in with the normal nan error, and then we could remove theis foo empty?in the error case.retroj commentedon Feb 23, 2017
@robd I like your idea. The current warning is oddly ambiguous, and to my thinking, outside of the concern of a progress reporter.
leehambley commentedon Feb 23, 2017
Alright, so to summarize, if we all agree?
Was that the consensus?
mattbrictson commentedon Feb 23, 2017
Sounds like consensus! Would anyone like to contribute a PR to implement the agreed behavior?