for moved volumes, redirect with code 501
This commit is contained in:
34
weed-fs/src/pkg/operation/lookup.go
Normal file
34
weed-fs/src/pkg/operation/lookup.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package operation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"pkg/storage"
|
||||
"pkg/util"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Location struct {
|
||||
Url string "url"
|
||||
PublicUrl string "publicUrl"
|
||||
}
|
||||
type LookupResult struct {
|
||||
Locations []Location "locations"
|
||||
Error string "error"
|
||||
}
|
||||
|
||||
func Lookup(server string, vid storage.VolumeId) (*LookupResult, error) {
|
||||
values := make(url.Values)
|
||||
values.Add("volumeId", vid.String())
|
||||
jsonBlob, err := util.Post("http://"+server+"/dir/lookup", values)
|
||||
fmt.Println("Lookup Result:", string(jsonBlob))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ret LookupResult
|
||||
err = json.Unmarshal(jsonBlob, &ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
@@ -136,6 +136,11 @@ func (s *Store) Read(i VolumeId, n *Needle) (int, error) {
|
||||
return 0, errors.New("Not Found")
|
||||
}
|
||||
|
||||
func (s *Store) HasVolume(i VolumeId) bool {
|
||||
_, ok := s.volumes[i]
|
||||
return ok
|
||||
}
|
||||
|
||||
type VolumeLocations struct {
|
||||
Vid VolumeId
|
||||
Locations []string
|
||||
|
||||
Reference in New Issue
Block a user