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

Small improve on deleting attachements #3145

Merged
merged 3 commits into from
Dec 24, 2017

Conversation

lunny
Copy link
Member

@lunny lunny commented Dec 11, 2017

As title.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Dec 11, 2017
@lunny lunny added this to the 1.4.0 milestone Dec 11, 2017
@codecov-io
Copy link

codecov-io commented Dec 11, 2017

Codecov Report

Merging #3145 into master will decrease coverage by 0.19%.
The diff coverage is 57.14%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #3145     +/-   ##
========================================
- Coverage    34.9%   34.7%   -0.2%     
========================================
  Files         277     277             
  Lines       40108   40116      +8     
========================================
- Hits        13998   13922     -76     
- Misses      24061   24159     +98     
+ Partials     2049    2035     -14
Impacted Files Coverage Δ
models/attachment.go 49.48% <57.14%> (+1.16%) ⬆️
modules/lfs/content_store.go 7.81% <0%> (-35.94%) ⬇️
modules/lfs/server.go 20.68% <0%> (-14.33%) ⬇️
models/lfs.go 26.08% <0%> (-2.18%) ⬇️
models/repo_indexer.go 50.97% <0%> (-0.98%) ⬇️
models/repo.go 43.2% <0%> (-0.19%) ⬇️
models/repo_list.go 67.18% <0%> (+1.56%) ⬆️

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 cc7b8e3...7181b52. Read the comment docs.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 11, 2017
@lafriks
Copy link
Member

lafriks commented Dec 11, 2017

LGTM

@tboerger tboerger 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 Dec 11, 2017
return 0, nil
}

var ids = make([]int64, 0, len(attachments))
for i, a := range attachments {
if remove {
if err := os.Remove(a.LocalPath()); err != nil {
return i, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, there are some attachments which we have already deleted from the filesystem. Should we also remove them from the DB, so that the DB doesn't contain non-existent attachments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional check could be added to check if error is about nonexistent file but if error is that file can not be deleted (access denied etc) than it should stay as it is now

@lunny lunny force-pushed the lunny/improve_delete_attachements branch from ae1f337 to 2942b7a Compare December 23, 2017 06:36
@lunny
Copy link
Member Author

lunny commented Dec 23, 2017

@lafriks @ethantkoenig done.

Copy link
Member

@ethantkoenig ethantkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the change.

Could we please add a unit test for DeleteAttachments?

@lunny
Copy link
Member Author

lunny commented Dec 24, 2017

@ethantkoenig the tests have existed in attachment_test.go which will test DeleteAttachmentsByIssue and DeleteAttachmentsByComment but that in fact will finally call DeleteAttachments.

@ethantkoenig
Copy link
Member

LGTM

@tboerger tboerger 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 Dec 24, 2017
@lafriks lafriks merged commit f5155b9 into go-gitea:master Dec 24, 2017
@lunny lunny deleted the lunny/improve_delete_attachements branch December 25, 2017 00:43
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 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/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants