Loading main.go +0 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,6 @@ func Client(uri string) { } func main() { Loading rsync/demultiplex.go +1 −1 Original line number Diff line number Diff line Loading @@ -249,7 +249,7 @@ func GetFile(data chan byte, index int32, filelist *FileList) { } } log.Println("Buff Total size:", buf.Len()) lookup(int64(buf.Len()), filelist) //lookup(int64(buf.Len()), filelist) //ioutil.WriteFile("temp.txt", buf.Bytes(), 0644) WriteOS(buf, path) Loading rsync/receiver.go +16 −4 Original line number Diff line number Diff line Loading @@ -183,9 +183,10 @@ func GetFileList(data chan byte, filelist *FileList) error { /* Generator */ func RequestFiles(conn net.Conn, data chan byte, filelist *FileList, os *minio.Client, module string, ppath string) { func RequestFiles(conn net.Conn, data chan byte, filelist *FileList, os *minio.Client, module string, prepath string) { empty := make([]byte, 16) // 4 + 4 + 4 + 4 bytes for i:=0; i < len(*filelist); i++ { // TODO: Supports more file mode if (*filelist)[i].Mode == 0100644 { binary.Write(conn, binary.LittleEndian, int32(i)) Loading @@ -198,7 +199,7 @@ func RequestFiles(conn net.Conn, data chan byte, filelist *FileList, os *minio.C log.Println("Request completed") // Finish binary.Write(conn, binary.LittleEndian, int32(-1)) Downloader(data, filelist, os, module, ppath) Downloader(data, filelist, os, module, prepath) } func RequestAFile(conn net.Conn, target string, filelist *FileList) { Loading Loading @@ -235,7 +236,18 @@ func RequestAFile(conn net.Conn, target string, filelist *FileList) { binary.Write(conn, binary.LittleEndian, int32(-1)) } func Downloader(data chan byte, filelist *FileList, os *minio.Client, module string, ppath string) { func Downloader(data chan byte, filelist *FileList, os *minio.Client, module string, prepath string) { //pre-path shouldn't use "/" as prefix, and must have a "/" suffix //pre-path can be: "xx", "xx/", "/xx", "/xx/", "", "/" ppath := prepath if !strings.HasSuffix(ppath, "/") { ppath += "/" } if strings.HasPrefix(ppath, "/") { ppath = ppath[1:] } for { index := GetInteger(data) if index == -1 { Loading Loading @@ -267,7 +279,7 @@ func Downloader(data chan byte, filelist *FileList, os *minio.Client, module str } // Put file to object storage n, err := os.PutObject(module, (ppath+path)[1:], buf, int64(buf.Len()), minio.PutObjectOptions{}) n, err := os.PutObject(module, ppath+path, buf, int64(buf.Len()), minio.PutObjectOptions{}) if err != nil { log.Fatalln(err) } Loading Loading
main.go +0 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,6 @@ func Client(uri string) { } func main() { Loading
rsync/demultiplex.go +1 −1 Original line number Diff line number Diff line Loading @@ -249,7 +249,7 @@ func GetFile(data chan byte, index int32, filelist *FileList) { } } log.Println("Buff Total size:", buf.Len()) lookup(int64(buf.Len()), filelist) //lookup(int64(buf.Len()), filelist) //ioutil.WriteFile("temp.txt", buf.Bytes(), 0644) WriteOS(buf, path) Loading
rsync/receiver.go +16 −4 Original line number Diff line number Diff line Loading @@ -183,9 +183,10 @@ func GetFileList(data chan byte, filelist *FileList) error { /* Generator */ func RequestFiles(conn net.Conn, data chan byte, filelist *FileList, os *minio.Client, module string, ppath string) { func RequestFiles(conn net.Conn, data chan byte, filelist *FileList, os *minio.Client, module string, prepath string) { empty := make([]byte, 16) // 4 + 4 + 4 + 4 bytes for i:=0; i < len(*filelist); i++ { // TODO: Supports more file mode if (*filelist)[i].Mode == 0100644 { binary.Write(conn, binary.LittleEndian, int32(i)) Loading @@ -198,7 +199,7 @@ func RequestFiles(conn net.Conn, data chan byte, filelist *FileList, os *minio.C log.Println("Request completed") // Finish binary.Write(conn, binary.LittleEndian, int32(-1)) Downloader(data, filelist, os, module, ppath) Downloader(data, filelist, os, module, prepath) } func RequestAFile(conn net.Conn, target string, filelist *FileList) { Loading Loading @@ -235,7 +236,18 @@ func RequestAFile(conn net.Conn, target string, filelist *FileList) { binary.Write(conn, binary.LittleEndian, int32(-1)) } func Downloader(data chan byte, filelist *FileList, os *minio.Client, module string, ppath string) { func Downloader(data chan byte, filelist *FileList, os *minio.Client, module string, prepath string) { //pre-path shouldn't use "/" as prefix, and must have a "/" suffix //pre-path can be: "xx", "xx/", "/xx", "/xx/", "", "/" ppath := prepath if !strings.HasSuffix(ppath, "/") { ppath += "/" } if strings.HasPrefix(ppath, "/") { ppath = ppath[1:] } for { index := GetInteger(data) if index == -1 { Loading Loading @@ -267,7 +279,7 @@ func Downloader(data chan byte, filelist *FileList, os *minio.Client, module str } // Put file to object storage n, err := os.PutObject(module, (ppath+path)[1:], buf, int64(buf.Len()), minio.PutObjectOptions{}) n, err := os.PutObject(module, ppath+path, buf, int64(buf.Len()), minio.PutObjectOptions{}) if err != nil { log.Fatalln(err) } Loading