77 "path"
88 "strings"
99 "time"
10+ "unicode/utf8"
1011
1112 "github.com/StarHack/go-internxt-drive/auth"
1213 "github.com/StarHack/go-internxt-drive/buckets"
@@ -287,7 +288,17 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
287288 remote := src .Remote ()
288289
289290 if strings .HasPrefix (remote , "." ) {
290- return nil , fs .ErrorFileNameTooLong
291+ return nil , fs .ErrorCantUploadEmptyFiles
292+ }
293+
294+ if strings .HasSuffix (remote , "." ) || ! utf8 .ValidString (remote ) {
295+ return & Object {
296+ f : f ,
297+ remote : remote ,
298+ uuid : "" ,
299+ size : src .Size (),
300+ modTime : src .ModTime (ctx ),
301+ }, nil
291302 }
292303
293304 if src .Size () <= 0 {
@@ -298,6 +309,7 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
298309 parentDir = strings .Trim (parentDir , "/" )
299310
300311 parentDir = encodePath (parentDir )
312+
301313 folderUUID , err := f .dirCache .FindDir (ctx , parentDir , true )
302314 if err != nil {
303315 return nil , err
@@ -464,7 +476,9 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
464476 }
465477
466478 if err := files .DeleteFile (o .f .cfg , o .uuid ); err != nil {
467- return err
479+ if ! strings .Contains (err .Error (), `"statusCode":404` ) && ! strings .Contains (err .Error (), "Not Found" ) {
480+ return err
481+ }
468482 }
469483
470484 meta , err := buckets .UploadFileStream (o .f .cfg , folderUUID , path .Base (o .remote ), in , src .Size (), src .ModTime (ctx ))
@@ -484,9 +498,17 @@ func (o *Object) Remove(ctx context.Context) error {
484498}
485499
486500func encodePath (path string ) string {
487- return strings .ReplaceAll (path , "\\ " , "%5C" )
501+ path = strings .ReplaceAll (path , "\\ " , "%5C" )
502+ if strings .HasSuffix (path , "." ) {
503+ path = path [:len (path )- 1 ] + "%2E"
504+ }
505+ return path
488506}
489507
490508func decodePath (path string ) string {
491- return strings .ReplaceAll (path , "%5C" , "\\ " )
509+ path = strings .ReplaceAll (path , "%5C" , "\\ " )
510+ if strings .HasSuffix (path , "%2E" ) {
511+ path = path [:len (path )- 3 ] + "."
512+ }
513+ return path
492514}
0 commit comments