|
|
@ -2,23 +2,15 @@ package operation |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.google.com/p/weed-fs/go/glog" |
|
|
|
"code.google.com/p/weed-fs/go/storage" |
|
|
|
"net/http" |
|
|
|
) |
|
|
|
|
|
|
|
func DeleteFile(server string, fileId string) error { |
|
|
|
fid, parseErr := storage.ParseFileId(fileId) |
|
|
|
if parseErr != nil { |
|
|
|
return parseErr |
|
|
|
} |
|
|
|
lookup, lookupError := Lookup(server, fid.VolumeId) |
|
|
|
if lookupError != nil { |
|
|
|
return lookupError |
|
|
|
} |
|
|
|
if len(lookup.Locations) == 0 { |
|
|
|
return nil |
|
|
|
fileUrl, err := LookupFileId(server, fileId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return Delete("http://" + lookup.Locations[0].PublicUrl + "/" + fileId) |
|
|
|
return Delete(fileUrl) |
|
|
|
} |
|
|
|
func Delete(url string) error { |
|
|
|
req, err := http.NewRequest("DELETE", url, nil) |
|
|
|