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

InternalServerError: no such file or directory when Downloading file with using File Locker. #1148

Closed
134130 opened this issue Jun 27, 2024 · 1 comment · Fixed by #1149
Closed
Labels

Comments

@134130
Copy link

134130 commented Jun 27, 2024

Describe the bug

  • When I try to get file in subdirectory, tusd returns 500 response.

To Reproduce
Steps to reproduce the behavior:

  1. Make your tusd server with http://127.0.0.1:8080/basedir
  2. curl 127.0.0.1:8080/basedir/some/your/sub-directory/file.jpeg
  3. See error: msg=InternalServerError message="open <Eliminated>/some/your/sub-directory/file.jpeg.lock.1967546860: no such file or directory"

Expected behavior

  • 404 Not Found should be right

Setup details
Please provide following details, if applicable to your situation:

  • Operating System: macOS (but may be in other systems too)
  • Used tusd version: v2.4.0
  • Used tusd data storage: disk store (also disk lock)
  • Used tusd configuration: my custom golang code. and It's not important on this situation.
  • Used tus client library: No. I just used curl.

func (handler *UnroutedHandler) GetFile(http.ResponseWriter, *http.Request) {
	// ...
	if handler.composer.UsesLocker {
		lock, err := handler.lockUpload(c, id) // <-- (1)
		if err != nil {
			handler.sendError(c, err)
			return
		}

		defer lock.Unlock()
	}
	// ...
}

func (handler *UnroutedHandler) lockUpload(c *httpContext, id string) (Lock, error) {
	// ...
	if err := lock.Lock(ctx, releaseLock); err != nil { // <-- (2)
		return nil, err // <-- (3) *fs.PathError (ENOENT)
	}
	// ...
}
  • I've tried to open PR, but It looks uncertain where to handle this error.
    • In lockfile, It doesn't seems to proper to handle "no file".
    • In func lockUpload(), the lock is abstracted, so it also doesn't look like proper to handle "no file" too.
@Acconut
Copy link
Member

Acconut commented Jun 27, 2024

Thank you for reporting this. I opened #1149 to fix this by including a check in filelocker. I agree with your concerns that this might not be the best place for this check as filelocker should not directly rely on the folder structure that is created by the filestore. However, this is currently already the case and filelocker will put the .lock file next to the .info file in the directory created by filestore. We can revisit this architecture in the future and decide if we want to decouple them more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants