diff --git a/cmd/data-scanner.go b/cmd/data-scanner.go index 25b5c5cd0..1c982a9a4 100644 --- a/cmd/data-scanner.go +++ b/cmd/data-scanner.go @@ -44,7 +44,7 @@ import ( const ( dataScannerSleepPerFolder = time.Millisecond // Time to wait between folders. - dataScannerStartDelay = 1 * time.Minute // Time to wait on startup and between cycles. + dataScannerStartDelay = 5 * time.Minute // Time to wait on startup and between cycles. dataUsageUpdateDirCycles = 16 // Visit all folders every n cycles. healDeleteDangling = true diff --git a/cmd/storage-rest-client.go b/cmd/storage-rest-client.go index a3a72f800..cd77fa78a 100644 --- a/cmd/storage-rest-client.go +++ b/cmd/storage-rest-client.go @@ -337,8 +337,10 @@ func (client *storageRESTClient) CreateFile(ctx context.Context, volume, path st values.Set(storageRESTFilePath, path) values.Set(storageRESTLength, strconv.Itoa(int(size))) respBody, err := client.call(ctx, storageRESTMethodCreateFile, values, ioutil.NopCloser(reader), size) - defer http.DrainBody(respBody) - return err + if err != nil { + return err + } + return waitForHTTPStream(respBody, ioutil.Discard) } func (client *storageRESTClient) WriteMetadata(ctx context.Context, volume, path string, fi FileInfo) error { diff --git a/cmd/storage-rest-server.go b/cmd/storage-rest-server.go index baf3e9070..c93e5ab16 100644 --- a/cmd/storage-rest-server.go +++ b/cmd/storage-rest-server.go @@ -287,10 +287,10 @@ func (s *storageRESTServer) CreateFileHandler(w http.ResponseWriter, r *http.Req s.writeErrorResponse(w, err) return } - err = s.storage.CreateFile(r.Context(), volume, filePath, int64(fileSize), r.Body) - if err != nil { - s.writeErrorResponse(w, err) - } + + done := keepHTTPResponseAlive(w) + done(s.storage.CreateFile(r.Context(), volume, filePath, int64(fileSize), r.Body)) + w.(http.Flusher).Flush() } // DeleteVersion delete updated metadata.