Skip to content
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

Re-attempt to delete temporary upload if the file is locked by another process #12447

Merged
merged 14 commits into from
Aug 11, 2020

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Aug 6, 2020

Fix #12339

Signed-off-by: Andrew Thornton art27@cantab.net

Fix go-gitea#12339

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added this to the 1.13.0 milestone Aug 6, 2020
@zeripath zeripath changed the title Re-attempt to delete temporary upload if the process is locked Re-attempt to delete temporary upload if the file is locked by another process Aug 6, 2020
models/upload.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 6, 2020
@silverwind
Copy link
Member

File deletion on Windows can be a pain with the locking. I wonder if there are any third-party golang modules similar to https://github.com/isaacs/rimraf/blob/master/rimraf.js that deal with the various error scenarios.

@zeripath
Copy link
Contributor Author

zeripath commented Aug 8, 2020

Fine. Let's do this properly - replace all uses of os.Remove / os.RemoveAll with util.Remove / util.RemoveAll which will reattempt on certain errors.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath mentioned this pull request Aug 9, 2020
6 tasks
modules/util/remove.go Outdated Show resolved Hide resolved
modules/util/remove.go Outdated Show resolved Hide resolved
models/upload.go Outdated Show resolved Hide resolved
Co-authored-by: silverwind <me@silverwind.io>
models/upload.go Outdated Show resolved Hide resolved
go.sum Outdated Show resolved Hide resolved
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 11, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 11, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2020

Codecov Report

Merging #12447 into master will decrease coverage by 0.00%.
The diff coverage is 32.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12447      +/-   ##
==========================================
- Coverage   43.80%   43.79%   -0.01%     
==========================================
  Files         630      631       +1     
  Lines       69821    69851      +30     
==========================================
+ Hits        30585    30594       +9     
- Misses      34300    34311      +11     
- Partials     4936     4946      +10     
Impacted Files Coverage Δ
cmd/doctor.go 0.00% <0.00%> (ø)
cmd/dump.go 1.04% <0.00%> (-0.02%) ⬇️
models/admin.go 80.85% <0.00%> (ø)
models/attachment.go 57.74% <0.00%> (-1.41%) ⬇️
models/migrations/v112.go 0.00% <0.00%> (ø)
models/migrations/v115.go 0.00% <0.00%> (ø)
models/migrations/v96.go 0.00% <0.00%> (ø)
models/org.go 73.61% <0.00%> (ø)
models/repo.go 55.56% <0.00%> (ø)
models/upload.go 0.00% <0.00%> (ø)
... and 40 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update faa676c...47b9414. Read the comment docs.

@zeripath zeripath merged commit 74bd969 into go-gitea:master Aug 11, 2020
@zeripath zeripath deleted the fix-12339-file-locked branch August 11, 2020 20:05
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when uploading images
5 participants