Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Nov 8, 2023
1 parent 61596f3 commit d09b746
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
16 changes: 8 additions & 8 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func (f dirinfo) LessThan(f2 dirinfo) bool {
type Client struct {
BasePath string

AlwaysChecksum bool
ParallelFile, ParalllelDir int
PreserveHardlinks bool
BlockSize int
AlwaysChecksum bool
ParallelFile, ParallelDir int
PreserveHardlinks bool
BlockSize int

done bool

Expand All @@ -59,7 +59,7 @@ type Client struct {
func NewClient() *Client {
c := &Client{
ParallelFile: 4096,
ParalllelDir: 512,
ParallelDir: 512,
PreserveHardlinks: true,
BlockSize: 128 * 1024,
}
Expand All @@ -74,10 +74,10 @@ func (c *Client) Run(client *rpc.Client) error {

var listfilesActive sync.WaitGroup

c.dirstack, c.dirqueueout, c.dirqueuein = NewStack[FileInfo](c.ParalllelDir*2, 8)
c.dirstack, c.dirqueueout, c.dirqueuein = NewStack[FileInfo](c.ParallelDir*2, 8)
c.filequeue = make(chan FileInfo, c.ParallelFile*16)

for i := 0; i < c.ParalllelDir; i++ {
for i := 0; i < c.ParallelDir; i++ {
c.dirWorkerWG.Add(1)
go func() {
logger.Trace().Msg("Starting directory worker")
Expand Down Expand Up @@ -209,7 +209,7 @@ func (c *Client) Run(client *rpc.Client) error {

if !create_file {
// if it's a hardlinked file, check that it's linked correctly
if remotefi.Nlink > 1 {
if remotefi.Nlink > 1 && c.PreserveHardlinks {
if ini, found := c.inodes.Load(inodeinfo{
inode: remotefi.Inode,
}); found {
Expand Down
1 change: 1 addition & 0 deletions fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func InfoToFileInfo(info os.FileInfo, absolutepath string) (FileInfo, error) {
}

func (fi FileInfo) Compare(fi2 FileInfo) (different, requiresDelete bool) {
panic("not implemented")
return false, false
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func main() {
c := NewClient()
c.BasePath = *directory
c.PreserveHardlinks = *hardlinks
c.ParalllelDir = *paralleldir
c.ParallelDir = *paralleldir
c.ParallelFile = *parallelfile
c.BlockSize = *transferblocksize
c.AlwaysChecksum = *checksum
Expand Down
8 changes: 4 additions & 4 deletions readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ FastSync consists of:
Start up the source side, listening for unauthenticated clients

```bash
fastsync [--folder /your/source/folder] [--bind 0.0.0.0:7331] server
fastsync [--directory /your/source/directory] [--bind 0.0.0.0:7331] server
```

## Client mode

Connects to the server and starts syncing files to the client

```bash
fastsync [--hardlinks true] [--checksum false] [--pfile 4096] [--pdir 512] [--loglevel info] [--blocksize 131072] [--statsinterval 5] [--queueinterval 30] [--folder /your/target/folder] [--bind serverip:7331] client
fastsync [--hardlinks true] [--checksum false] [--pfile 4096] [--pdir 512] [--loglevel info] [--blocksize 131072] [--statsinterval 5] [--queueinterval 30] [--directory /your/target/directory] [--bind serverip:7331] client
```

Options:

- ```pfile``` sets the number of parallel file IO operations, for large RAID systems with lots of drives or flash storage the default 4096 is probably okay, but expect major load on both systems
- ```pdir``` sets the number of parallel folder listing operations
- ```pdir``` sets the number of parallel directory listing operations

- ```checksum``` forces fastsync to check all data on all existing files using checksums for every block (otherwise it assumes files with same size, timestamp and attributes are equal)

Expand All @@ -54,4 +54,4 @@ Options:
Current limitations:

- does not delete files on target that do not exist on the source
- only works on Linux, as there is a lot of Posix specific code regarding inodes, owner etc.
- does not work on Windows, as there is a lot of Posix specific code regarding inodes, owner etc.

0 comments on commit d09b746

Please sign in to comment.