protondrive: fix dereferencing nil pointer bug when obtaining additional

file attributes
This commit is contained in:
Chun-Hung Tseng 2023-08-02 18:58:09 +02:00
parent 63ab250817
commit 70f621e542
3 changed files with 11 additions and 7 deletions

View File

@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"log"
"path"
"strings"
"time"
@ -787,7 +786,6 @@ func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error) {
}
// sha1 not cached
log.Println("sha1 not cached")
// we fetch and try to obtain the sha1 of the link
fileSystemAttrs, err := o.fs.protonDrive.GetActiveRevisionAttrsByID(ctx, o.ID())
if err != nil {
@ -795,7 +793,7 @@ func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error) {
}
if fileSystemAttrs == nil || fileSystemAttrs.Digests == "" {
fs.Debugf(o, "file sha1 digest missing")
fs.Infof(o, "file sha1 digest missing")
return "", nil
}
return fileSystemAttrs.Digests, nil
@ -810,7 +808,7 @@ func (o *Object) Size() int64 {
return *o.originalSize
}
fs.Errorf(o, "Original size should exist")
fs.Infof(o, "Original size should exist")
}
return o.size
}
@ -868,7 +866,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadClo
o.digests = &fileSystemAttrs.Digests
o.blockSizes = fileSystemAttrs.BlockSizes
} else {
fs.Debugf(o, "fileSystemAttrs is nil: using fallback size, and now digests and blocksizes available")
fs.Infof(o, "fileSystemAttrs is nil: using fallback size, and now digests and blocksizes available")
o.originalSize = &sizeOnServer
o.size = sizeOnServer
o.digests = nil

4
go.mod
View File

@ -28,8 +28,8 @@ require (
github.com/go-chi/chi/v5 v5.0.10
github.com/google/uuid v1.3.1
github.com/hanwen/go-fuse/v2 v2.3.0
github.com/henrybear327/Proton-API-Bridge v0.0.0-20230906013317-762502d1fb60
github.com/henrybear327/go-proton-api v0.0.0-20230905230058-67e3daa437a2
github.com/henrybear327/Proton-API-Bridge v0.0.0-20230905213240-631e8468569e
github.com/henrybear327/go-proton-api v0.0.0-20230905210903-1d7952498156
github.com/hirochachacha/go-smb2 v1.1.0
github.com/iguanesolutions/go-systemd/v5 v5.1.1
github.com/jcmturner/gokrb5/v8 v8.4.4

6
go.sum
View File

@ -296,10 +296,16 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/henrybear327/Proton-API-Bridge v0.0.0-20230905213240-631e8468569e h1:2DnsPnCaMZfwXvEYXxZPPc8nBfwvmuCyVWPvgcAu4XA=
github.com/henrybear327/Proton-API-Bridge v0.0.0-20230905213240-631e8468569e/go.mod h1:79lPvh2duLpDDfXN5XThz6QBa3cfKljDChWDpNSC1jY=
github.com/henrybear327/Proton-API-Bridge v0.0.0-20230906013317-762502d1fb60 h1:EqMPJXqpoFGqkMd2RFMPpo/hRBYI9j2nGoAHXaC932Q=
github.com/henrybear327/Proton-API-Bridge v0.0.0-20230906013317-762502d1fb60/go.mod h1:79lPvh2duLpDDfXN5XThz6QBa3cfKljDChWDpNSC1jY=
github.com/henrybear327/go-proton-api v0.0.0-20230905210903-1d7952498156 h1:4AneKd+c3c1Jq9X5FRrbJwqhn5M0lkc38xDuP+nl8M8=
github.com/henrybear327/go-proton-api v0.0.0-20230905210903-1d7952498156/go.mod h1:w63MZuzufKcIZ93pwRgiOtxMXYafI8H74D77AxytOBc=
github.com/henrybear327/go-proton-api v0.0.0-20230905230058-67e3daa437a2 h1:6qH4QnxEDNwWrKG/qqikGGg5SzUJezYSJyB36Glu3No=
github.com/henrybear327/go-proton-api v0.0.0-20230905230058-67e3daa437a2/go.mod h1:w63MZuzufKcIZ93pwRgiOtxMXYafI8H74D77AxytOBc=
github.com/henrybear327/go-proton-api v0.0.0-20230906134636-5b5c50c41b71 h1:0b/Jimd0S8wpQTUKKD86RJkgk3Ehzivs2k5XUlYMk74=
github.com/henrybear327/go-proton-api v0.0.0-20230906134636-5b5c50c41b71/go.mod h1:w63MZuzufKcIZ93pwRgiOtxMXYafI8H74D77AxytOBc=
github.com/hirochachacha/go-smb2 v1.1.0 h1:b6hs9qKIql9eVXAiN0M2wSFY5xnhbHAQoCwRKbaRTZI=
github.com/hirochachacha/go-smb2 v1.1.0/go.mod h1:8F1A4d5EZzrGu5R7PU163UcMRDJQl4FtcxjBfsY8TZE=
github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo=