Esempio n. 1
0
func MatchFile(srcFile *fs.File, dst string) (match *FileMatch, err error) {
	srcBlockIndex := fs.IndexBlocks(srcFile)

	match, err = MatchIndex(srcBlockIndex, dst)
	if match != nil {
		match.SrcSize = srcFile.Size
	}

	return match, err
}
Esempio n. 2
0
func (store *RemoteStore) Pull() os.Error {
	req, err := http.NewRequest("GET",
		fmt.Sprintf("%s/%s", store.url, web.NODEROOT), nil)
	if err != nil {
		return err
	}

	resp, err := store.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	decoder := gob.NewDecoder(resp.Body)

	store.root = &fs.Dir{}
	err = decoder.Decode(store.root)
	if err != nil {
		return err
	}

	store.index = fs.IndexBlocks(store.root)
	return nil
}
Esempio n. 3
0
func (store *RemoteStore) Index() *fs.BlockIndex {
	if store.index == nil {
		store.index = fs.IndexBlocks(store.root)
	}
	return store.index
}