Merge master
This commit is contained in:
parent
608795b322
commit
ad5e486ba0
|
@ -55,3 +55,9 @@ type DataStore interface {
|
|||
// and writing, must return os.ErrNotExist or similar.
|
||||
Terminate(id string) error
|
||||
}
|
||||
|
||||
type FinisherDataStore interface {
|
||||
DataStore
|
||||
|
||||
FinishUpload(id string) error
|
||||
}
|
||||
|
|
|
@ -369,10 +369,21 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request
|
|||
newOffset := offset + bytesWritten
|
||||
w.Header().Set("Upload-Offset", strconv.FormatInt(newOffset, 10))
|
||||
|
||||
// If the upload is completed, send the info out to the channel
|
||||
if handler.config.NotifyCompleteUploads && newOffset == info.Size {
|
||||
info.Size = newOffset
|
||||
handler.CompleteUploads <- info
|
||||
// If the upload is completed, ...
|
||||
if newOffset == info.Size {
|
||||
// ... allow custom mechanism to finish and cleanup the upload
|
||||
if store, ok := handler.dataStore.(FinisherDataStore); ok {
|
||||
if err := store.FinishUpload(id); err != nil {
|
||||
handler.sendError(w, r, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// ... send the info out to the channel
|
||||
if handler.config.NotifyCompleteUploads {
|
||||
info.Size = newOffset
|
||||
handler.CompleteUploads <- info
|
||||
}
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
|
|
Loading…
Reference in New Issue