Skip to content

remove upload: remove #13611

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

Closed
aszswaz opened this issue Nov 18, 2020 · 5 comments · Fixed by #15042
Closed

remove upload: remove #13611

aszswaz opened this issue Nov 18, 2020 · 5 comments · Fixed by #15042
Labels

Comments

@aszswaz
Copy link

aszswaz commented Nov 18, 2020

When using the file upload function of gitea, an error occurred. How can I solve this? Going back to the warehouse page, you can see that the file upload was successful, but the upload cache file deletion failed.
The error message is:
remove upload: remove C:/Program Files/gitea/data/tmp/uploads/a/d/ad727a50-7d9d-4ae4-bcef-25f4e58fd2d6: The process cannot access the file because it is being used by another process.

@lunny
Copy link
Member

lunny commented Nov 18, 2020

It seems it's a bug. The file point isn't closed.

@aszswaz
Copy link
Author

aszswaz commented Nov 20, 2020

It seems it's a bug. The file point isn't closed.

Thanks for the answer, that is to say, this bug cannot be solved by modifying the configuration file?

@6543
Copy link
Member

6543 commented Nov 24, 2020

@aszswaz it would be nice if you can add some information about your gitea.

  • version
  • dbms
  • os = windows10?
  • logs?

@6543 6543 added type/bug issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail labels Nov 24, 2020
@garfeng
Copy link

garfeng commented Mar 19, 2021

上传文件至 '' 时发生错误:remove upload: remove G:/tmp/gitea-1.13.4-windows-4.0-amd64.exe/data/tmp/uploads/4/f/4f13785e-3e6a-4539-8714-ef3bae1c4ed8: The process cannot access the file because it is being used by another process.

log:

2021/03/19 13:06:34 ...uters/repo/editor.go:698:UploadFilePost() [E] Error during upload to repo: 1:garfeng/first to filepath:  on master from garfeng-patch-1: remove upload: remove G:/tmp/gitea-1.13.4-windows-4.0-amd64.exe/data/tmp/uploads/4/f/4f13785e-3e6a-4539-8714-ef3bae1c4ed8: The process cannot access the file because it is being used by another process.

os is win10

@6543

@garfeng
Copy link

garfeng commented Mar 19, 2021

The bug is here.

// UploadRepoFiles uploads files to the given repository
func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRepoFileOptions) error {
	...
	for i, uploadInfo := range infos {
		file, err := os.Open(uploadInfo.upload.LocalPath()) 
		if err != nil {
			return err
		}
		defer file.Close() // bug !!
		...
	}
	...
	return return models.DeleteUploads(uploads...) // the file handles are still not closed yet
}

Please do like this:

// UploadRepoFiles uploads files to the given repository
func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRepoFileOptions) error {
	for i, uploadInfo := range infos {
		func() {
			file, err := os.Open(uploadInfo.upload.LocalPath())
			if err != nil {
				return err
			}
			defer file.Close() // the file handle will be closed when the anonymous func return
			...
		}()
		
	}
	...
	return return models.DeleteUploads(uploads...)
}

@6543

@lunny lunny removed the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Mar 19, 2021
@go-gitea go-gitea locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants