Skip to content

[WIP] Use tus for uploads (and support range requests for downloads?) - #286

Closed
butonic wants to merge 8 commits into
cs3org:masterfrom
owncloud:feature/tus
Closed

butonic wants to merge 8 commits into
cs3org:masterfrom
owncloud:feature/tus

Conversation

@butonic

@butonic butonic commented Oct 4, 2019 •

Copy link
Copy Markdown
Contributor

replace datasvc with tusdsvc ... or teach datasvc some tus tricks ... fixes #284

currently needs tus/tusd#309

Comment thread pkg/storage/fs/owncloud/owncloud.go Resolved
Comment thread pkg/storage/fs/owncloud/owncloud.go Resolved
Comment thread pkg/storage/fs/eos/eos.go Resolved
Comment thread pkg/storage/fs/local/local.go Resolved
Comment thread pkg/storage/fs/owncloud/owncloud.go Resolved
}

// infoPath returns the path to the .info file storing the file's info.
func (store OwnCloudStore) infoPath(ctx context.Context, id string) (string, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

func OwnCloudStore.infoPath is unused (from unused)

Comment thread pkg/storage/fs/owncloud/owncloud.go Resolved
Comment thread pkg/storage/fs/owncloud/owncloud.go Resolved
Comment thread pkg/storage/fs/owncloud/owncloud.go Resolved
tusd "github.com/tus/tusd/pkg/handler"
)

const UploadLengthDeferred = "1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exported const UploadLengthDeferred should have comment or be unexported

haveInvalidDeferHeader := uploadDeferLengthHeader != "" && uploadDeferLengthHeader != UploadLengthDeferred
lengthIsDeferred := uploadDeferLengthHeader == UploadLengthDeferred

if lengthIsDeferred && !handler.composer.UsesLengthDeferrer {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ifElseChain: rewrite if-else to switch statement (from gocritic)

// Directly finish the upload if the upload is empty (i.e. has a size of 0).
// This statement is in an else-if block to avoid causing duplicate calls
// to finishUploadIfComplete if an upload is empty and contains a chunk.
handler.finishUploadIfComplete(ctx, upload, info, r)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of handler.finishUploadIfComplete is not checked (from errcheck)

return
}

defer lock.Unlock()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of lock.Unlock is not checked (from errcheck)

return
}

defer lock.Unlock()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of lock.Unlock is not checked (from errcheck)

}

handler.sendResp(w, r, http.StatusOK)
io.Copy(w, src)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of io.Copy is not checked (from errcheck)

w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("Content-Length", strconv.Itoa(len(reason)))
w.WriteHeader(statusErr.StatusCode())
w.Write(reason)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of w.Write is not checked (from errcheck)

@butonic

butonic commented Oct 4, 2019

Copy link
Copy Markdown
Contributor Author

aside from the noise above what really now is missing is an async process to propagate the etag, mtime and size changes. I want to trigger that only after the file upload is finished AND a possible workflow has happened (eg antivirus scan). eos should magically work without this. but for the owncloud storage driver this piece is still missing.

  • put the propagation code in the storage driver
  • have it subscribe to a redis channel, we already use redis for fileid to path lookup
  • publish the path when a file is changed from the tusd svc
  • publish the path when a folder changed ... can we throttle this? deduplicate events?
  • add a reva cmd that publishes a message. can then be used by inotify to trigger external changes ... hm ... or do we want to rely on inotify, see [WIP] storage/local notify #78
  • refactor this pr so it replaces the datasvc

}

var (
ErrUnsupportedVersion = NewHTTPError(errors.New("unsupported version"), http.StatusPreconditionFailed)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exported var ErrUnsupportedVersion should have comment or be unexported

LogEvent(h.logger, eventName, details...)
}

func LogEvent(logger *log.Logger, eventName string, details ...string) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exported function LogEvent should have comment or be unexported

haveInvalidDeferHeader := uploadDeferLengthHeader != "" && uploadDeferLengthHeader != UploadLengthDeferred
lengthIsDeferred := uploadDeferLengthHeader == UploadLengthDeferred

if lengthIsDeferred && !handler.composer.UsesLengthDeferrer {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ifElseChain: rewrite if-else to switch statement (from gocritic)

// UploadProgress is used to send notifications about the progress of the
// currently running uploads. For each open PATCH request, every second
// a HookEvent instance will be send over this channel with the Offset field
// being set to the number of bytes which have been transfered to the server.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

transfered is a misspelling of transferred (from misspell)

Suggested change
// being set to the number of bytes which have been transfered to the server.

// mimeInlineBrowserWhitelist is a map containing MIME types which should be
// allowed to be rendered by browser inline, instead of being forced to be
// downloadd. For example, HTML or SVG files are not allowed, since they may
// contain malicious JavaScript. In a similiar fashion PDF is not on this list

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

similiar is a misspelling of similar (from misspell)

Suggested change
// contain malicious JavaScript. In a similiar fashion PDF is not on this list

// Directly finish the upload if the upload is empty (i.e. has a size of 0).
// This statement is in an else-if block to avoid causing duplicate calls
// to finishUploadIfComplete if an upload is empty and contains a chunk.
handler.finishUploadIfComplete(ctx, upload, info, r)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of handler.finishUploadIfComplete is not checked (from errcheck)

return
}

defer lock.Unlock()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of lock.Unlock is not checked (from errcheck)

return
}

defer lock.Unlock()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of lock.Unlock is not checked (from errcheck)

}

handler.sendResp(w, r, http.StatusOK)
io.Copy(w, src)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of io.Copy is not checked (from errcheck)

w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("Content-Length", strconv.Itoa(len(reason)))
w.WriteHeader(statusErr.StatusCode())
w.Write(reason)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of w.Write is not checked (from errcheck)

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
}

upload.info.Offset += n
upload.writeInfo()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error return value of upload.writeInfo is not checked (from errcheck)

@labkode labkode changed the title Use tus for uploads (and support range requests for downloads?) [WIP] Use tus for uploads (and support range requests for downloads?) Jan 10, 2020
@micbar micbar mentioned this pull request Apr 6, 2020
11 of 12 tasks
@butonic butonic mentioned this pull request Apr 15, 2020
6 tasks
@butonic butonic closed this Apr 21, 2020
kobergj pushed a commit to kobergj/reva that referenced this pull request Jun 12, 2025
…opentelemetry.io/otel/trace-1.36.0

[Build-deps]: bump go.opentelemetry.io/otel/trace from 1.32.0 to 1.36.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

replace datasvc with a tus.io capable endpoint

2 participants