Skip to content

Commit

Permalink
Fix linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed May 19, 2021
1 parent 9c8cd79 commit 1a1c384
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
11 changes: 7 additions & 4 deletions pkg/storage/fs/owncloudsql/filecache/filecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (c *Cache) Move(storage interface{}, sourcePath, targetPath string) error {
if err != nil {
return err
}
defer tx.Rollback()
defer func() { _ = tx.Rollback() }()
stmt, err := tx.Prepare("UPDATE oc_filecache SET parent=?, path=?, name=?, path_hash=? WHERE storage = ? and fileid=?")
if err != nil {
return err
Expand All @@ -361,15 +361,18 @@ func (c *Cache) Move(storage interface{}, sourcePath, targetPath string) error {
id int
path string
)
childRows.Scan(&id, &path)
err = childRows.Scan(&id, &path)
if err != nil {
return err
}

children[id] = path
}
for id, path := range children {
path = strings.Replace(path, sourcePath, targetPath, -1)
path = strings.ReplaceAll(path, sourcePath, targetPath)
phashBytes = md5.Sum([]byte(path))
_, err = stmt.Exec(source.ID, path, filepath.Base(path), hex.EncodeToString(phashBytes[:]), storageID, id)
if err != nil {
tx.Rollback()
return err
}
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/storage/fs/owncloudsql/filecache/filecache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ var _ = Describe("Filecache", func() {
dbData, err := ioutil.ReadFile("test.db")
Expect(err).ToNot(HaveOccurred())

testDbFile.Write(dbData)
testDbFile.Close()
_, err = testDbFile.Write(dbData)
Expect(err).ToNot(HaveOccurred())
err = testDbFile.Close()
Expect(err).ToNot(HaveOccurred())

sqldb, err = sql.Open("sqlite3", testDbFile.Name())
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -328,6 +330,7 @@ var _ = Describe("Filecache", func() {
Expect(entry.Etag).To(Equal("13cf411aefccd7183d3b117ccd0ac5f8"))

err = cache.SetEtag(1, "files/Photos/Portugal.jpg", "foo")
Expect(err).ToNot(HaveOccurred())

entry, err = cache.Get(1, "files/Photos/Portugal.jpg")
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -438,6 +441,7 @@ var _ = Describe("Filecache", func() {
}

existingEntry, err := cache.Get(1, "files/Photos/Portugal.jpg")
Expect(err).ToNot(HaveOccurred())
_, err = cache.Copy(1, "files/Photos/Portugal.jpg", "files_versions/Photos/Portugal.jpg.v1619528083")
Expect(err).ToNot(HaveOccurred())

Expand Down
13 changes: 0 additions & 13 deletions pkg/storage/fs/owncloudsql/owncloudsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,12 @@ const (
// "user.oc."
ocPrefix string = "user.oc."

// idAttribute is the name of the filesystem extended attribute that is used to store the uuid in
idAttribute string = ocPrefix + "id"

// SharePrefix is the prefix for sharing related extended attributes
sharePrefix string = ocPrefix + "grant." // grants are similar to acls, but they are not propagated down the tree when being changed
trashOriginPrefix string = ocPrefix + "o"
mdPrefix string = ocPrefix + "md." // arbitrary metadata
favPrefix string = ocPrefix + "fav." // favorite flag, per user
etagPrefix string = ocPrefix + "etag." // allow overriding a calculated etag with one from the extended attributes
checksumPrefix string = ocPrefix + "cs." // TODO add checksum support
checksumsKey string = "http://owncloud.org/ns/checksums"
)

Expand Down Expand Up @@ -749,15 +745,6 @@ func (fs *ocfs) readPermissions(ctx context.Context, ip string) (p *provider.Res
return fs.filecache.Permissions(storageID, fs.toDatabasePath(ctx, ip))
}

func isNoData(err error) bool {
if xerr, ok := err.(*xattr.Error); ok {
if serr, ok2 := xerr.Err.(syscall.Errno); ok2 {
return serr == syscall.ENODATA
}
}
return false
}

// The os not exists error is buried inside the xattr error,
// so we cannot just use os.IsNotExists().
func isNotFound(err error) bool {
Expand Down

0 comments on commit 1a1c384

Please sign in to comment.