Skip to content

Commit f4df033

Browse files
committed
localfs upload logging
1 parent 320dc38 commit f4df033

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/storage/utils/localfs/upload.go

+6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ import (
4040
var defaultFilePerm = os.FileMode(0664)
4141

4242
func (fs *localfs) Upload(ctx context.Context, ref *provider.Reference, r io.ReadCloser, metadata map[string]string) error {
43+
log := appctx.GetLogger(ctx)
4344
upload, err := fs.GetUpload(ctx, ref.GetPath())
45+
log.Info().Any("upload", upload).Msg("localfs: upload")
4446
if err != nil {
4547
return errors.Wrap(err, "localfs: error retrieving upload")
4648
}
@@ -156,6 +158,7 @@ func (fs *localfs) NewUpload(ctx context.Context, info tusd.FileInfo) (upload tu
156158
info.ID = uuid.New().String()
157159

158160
binPath, err := fs.getUploadPath(ctx, info.ID)
161+
log.Info().Str("upload-path", binPath).Err(err).Msg("localfs: got upload path")
159162
if err != nil {
160163
return nil, errors.Wrap(err, "localfs: error resolving upload path")
161164
}
@@ -307,6 +310,7 @@ func (upload *fileUpload) writeInfo() error {
307310

308311
// FinishUpload finishes an upload and moves the file to the internal destination.
309312
func (upload *fileUpload) FinishUpload(ctx context.Context) error {
313+
log := appctx.GetLogger(ctx)
310314
np := upload.info.Storage["InternalDestination"]
311315

312316
// TODO check etag with If-Match header
@@ -318,6 +322,7 @@ func (upload *fileUpload) FinishUpload(ctx context.Context) error {
318322
//}
319323

320324
// if destination exists
325+
log.Info().Str("oldpath", upload.binPath).Str("newpath", np).Msg("localfs: FinishUpload")
321326
if _, err := os.Stat(np); err == nil {
322327
// create revision
323328
if err := upload.fs.archiveRevision(upload.ctx, np); err != nil {
@@ -327,6 +332,7 @@ func (upload *fileUpload) FinishUpload(ctx context.Context) error {
327332

328333
err := os.Rename(upload.binPath, np)
329334
if err != nil {
335+
log.Error().Msg("localfs: Failed to rename in FinishUpload")
330336
return err
331337
}
332338

0 commit comments

Comments
 (0)