From fa2a7b5f2ff85cd5975f3d261aa76494f3a1c71f Mon Sep 17 00:00:00 2001 From: DaLin Date: Sat, 11 Jun 2016 01:16:19 +0800 Subject: [PATCH] fix bug: filer DELETE --- weed/filer/cassandra_store/cassandra_store.go | 6 +++--- weed/filer/flat_namespace/flat_namespace_filer.go | 14 +++++++++++++- weed/filer/flat_namespace/flat_namespace_store.go | 2 +- weed/filer/redis_store/redis_store.go | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index 4ee2f65be..cdb9d3e3c 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -68,16 +68,16 @@ func (c *CassandraStore) Get(fullFileName string) (fid string, err error) { } // Currently the fid is not returned -func (c *CassandraStore) Delete(fullFileName string) (fid string, err error) { +func (c *CassandraStore) Delete(fullFileName string) (err error) { if err := c.session.Query( `DELETE FROM seaweed_files WHERE path = ?`, fullFileName).Exec(); err != nil { if err != gocql.ErrNotFound { glog.V(0).Infof("Failed to delete file %s: %v", fullFileName, err) } - return "", err + return err } - return "", nil + return nil } func (c *CassandraStore) Close() { diff --git a/weed/filer/flat_namespace/flat_namespace_filer.go b/weed/filer/flat_namespace/flat_namespace_filer.go index c20fd2521..f5e17b621 100644 --- a/weed/filer/flat_namespace/flat_namespace_filer.go +++ b/weed/filer/flat_namespace/flat_namespace_filer.go @@ -42,7 +42,19 @@ func (filer *FlatNamespaceFiler) DeleteDirectory(dirPath string, recursive bool) } func (filer *FlatNamespaceFiler) DeleteFile(fullFileName string) (fid string, err error) { - return filer.store.Delete(fullFileName) + fid, err = filer.FindFile(fullFileName) + if err != nil { + return "", err + } + + err = filer.store.Delete(fullFileName) + if err != nil { + return "", err + } + + return fid, nil + //return filer.store.Delete(fullFileName) + //are you kidding me!!!! } func (filer *FlatNamespaceFiler) Move(fromPath string, toPath string) error { diff --git a/weed/filer/flat_namespace/flat_namespace_store.go b/weed/filer/flat_namespace/flat_namespace_store.go index 832b70e40..dc158f7ad 100644 --- a/weed/filer/flat_namespace/flat_namespace_store.go +++ b/weed/filer/flat_namespace/flat_namespace_store.go @@ -5,5 +5,5 @@ import () type FlatNamespaceStore interface { Put(fullFileName string, fid string) (err error) Get(fullFileName string) (fid string, err error) - Delete(fullFileName string) (fid string, err error) + Delete(fullFileName string) (err error) } diff --git a/weed/filer/redis_store/redis_store.go b/weed/filer/redis_store/redis_store.go index 939172557..5e51b5455 100644 --- a/weed/filer/redis_store/redis_store.go +++ b/weed/filer/redis_store/redis_store.go @@ -33,12 +33,12 @@ func (s *RedisStore) Put(fullFileName string, fid string) (err error) { } // Currently the fid is not returned -func (s *RedisStore) Delete(fullFileName string) (fid string, err error) { +func (s *RedisStore) Delete(fullFileName string) (err error) { _, err = s.Client.Del(fullFileName).Result() if err == redis.Nil { err = nil } - return "", err + return err } func (s *RedisStore) Close() {