Commit f57f06aa authored by 黄大凯's avatar 黄大凯
Browse files

Add initial diff

parent c57fac16
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -15,9 +15,12 @@ type Cache struct {
func Open(module string, prepath string) {
	db, err := bolt.Open("r.db", 0666, nil)
	if err != nil {
		//return err
		return
	}
	tx, err := db.Begin(true)
	if tx == nil {
		return
	}
	defer tx.Rollback()

	_, err = tx.CreateBucketIfNotExists([]byte(module))
@@ -51,6 +54,16 @@ func (cache *Cache) Get(key []byte) *FInfo {
	return nil
}

func (cache *Cache) PutAll(list *rsync.FileList) error {
	for _, info := range *list {
		err := cache.Put(&info);
		if err != nil {
			return err
		}
	}
	return nil
}

func Save(list *rsync.FileList) {

}
+19 −1
Original line number Diff line number Diff line
package filelist

import "rsync2os/rsync"
import (
	"rsync2os/rsync"
)

// Diff two sorted list
// Return two lists: new files, deleted files
func (cache *Cache) Diff(list *rsync.FileList) (*rsync.FileList, *rsync.FileList) {

	// Interate cache.module(A) & list(B), both A & B must be sorted lexicographically before

	// Compare their path

	// bytes.Compare

	// The result will be 0 if a==b, -1 if a < b, and +1 if a > b

	// If > 0, B doesn't have

	// If == 0, A & B have

	// If < 0, A doesn't have

	return nil, nil
}
 No newline at end of file