@@ -162,6 +162,7 @@ func getUser(ctx context.Context) (*userpb.User, error) {
162
162
}
163
163
164
164
func (fs * localfs ) wrap (ctx context.Context , p string ) string {
165
+ log := appctx .GetLogger (ctx )
165
166
// This is to prevent path traversal.
166
167
// With this p can't break out of its parent folder
167
168
p = path .Join ("/" , p )
@@ -175,6 +176,7 @@ func (fs *localfs) wrap(ctx context.Context, p string) string {
175
176
} else {
176
177
internal = path .Join (fs .conf .DataDirectory , p )
177
178
}
179
+ log .Debug ().Str ("old" , p ).Str ("wrapped" , internal ).Msg ("localfs: wrap" )
178
180
return internal
179
181
}
180
182
@@ -842,6 +844,8 @@ func (fs *localfs) Delete(ctx context.Context, ref *provider.Reference) error {
842
844
}
843
845
844
846
func (fs * localfs ) Move (ctx context.Context , oldRef , newRef * provider.Reference ) error {
847
+ log := appctx .GetLogger (ctx )
848
+ log .Debug ().Any ("from" , oldRef ).Any ("to" , newRef ).Msg ("localfs: move" )
845
849
oldName , err := fs .resolve (ctx , oldRef )
846
850
if err != nil {
847
851
return errors .Wrap (err , "localfs: error resolving ref" )
@@ -860,6 +864,7 @@ func (fs *localfs) Move(ctx context.Context, oldRef, newRef *provider.Reference)
860
864
newName = fs .wrap (ctx , newName )
861
865
862
866
if err := os .Rename (oldName , newName ); err != nil {
867
+ log .Error ().Err (err ).Msg ("localfs: error moving " + oldName + " to " + newName )
863
868
return errors .Wrap (err , "localfs: error moving " + oldName + " to " + newName )
864
869
}
865
870
@@ -1062,7 +1067,10 @@ func (fs *localfs) listShareFolderRoot(ctx context.Context, home string, mdKeys
1062
1067
1063
1068
func (fs * localfs ) Download (ctx context.Context , ref * provider.Reference ) (io.ReadCloser , error ) {
1064
1069
fn , err := fs .resolve (ctx , ref )
1070
+ log := appctx .GetLogger (ctx )
1071
+
1065
1072
if err != nil {
1073
+ log .Error ().Err (err ).Any ("ref" , ref ).Msg ("localfs: error resolving ref" )
1066
1074
return nil , errors .Wrap (err , "localfs: error resolving ref" )
1067
1075
}
1068
1076
@@ -1074,8 +1082,10 @@ func (fs *localfs) Download(ctx context.Context, ref *provider.Reference) (io.Re
1074
1082
r , err := os .Open (fn )
1075
1083
if err != nil {
1076
1084
if os .IsNotExist (err ) {
1085
+ log .Error ().Err (err ).Str ("path" , fn ).Msg ("localfs: file not found" )
1077
1086
return nil , errtypes .NotFound (fn )
1078
1087
}
1088
+ log .Error ().Err (err ).Str ("path" , fn ).Msg ("localfs: error opening file" )
1079
1089
return nil , errors .Wrap (err , "localfs: error reading " + fn )
1080
1090
}
1081
1091
return r , nil
0 commit comments