diff --git a/libs/sync/diff.go b/libs/sync/diff.go new file mode 100644 index 00000000..eb5b9cba --- /dev/null +++ b/libs/sync/diff.go @@ -0,0 +1,29 @@ +package sync + +import ( + "fmt" + "strings" +) + +type diff struct { + put []string + delete []string +} + +func (d diff) IsEmpty() bool { + return len(d.put) == 0 && len(d.delete) == 0 +} + +func (d diff) String() string { + if d.IsEmpty() { + return "no changes" + } + var changes []string + if len(d.put) > 0 { + changes = append(changes, fmt.Sprintf("PUT: %s", strings.Join(d.put, ", "))) + } + if len(d.delete) > 0 { + changes = append(changes, fmt.Sprintf("DELETE: %s", strings.Join(d.delete, ", "))) + } + return strings.Join(changes, ", ") +} diff --git a/libs/sync/snapshot.go b/libs/sync/snapshot.go index 27f12b9b..20507053 100644 --- a/libs/sync/snapshot.go +++ b/libs/sync/snapshot.go @@ -66,11 +66,6 @@ type Snapshot struct { RemoteToLocalNames map[string]string `json:"remote_to_local_names"` } -type diff struct { - put []string - delete []string -} - const syncSnapshotDirName = "sync-snapshots" func GetFileName(host, remotePath string) string { @@ -170,24 +165,6 @@ func loadOrNewSnapshot(opts *SyncOptions) (*Snapshot, error) { return snapshot, nil } -func (d diff) IsEmpty() bool { - return len(d.put) == 0 && len(d.delete) == 0 -} - -func (d diff) String() string { - if d.IsEmpty() { - return "no changes" - } - var changes []string - if len(d.put) > 0 { - changes = append(changes, fmt.Sprintf("PUT: %s", strings.Join(d.put, ", "))) - } - if len(d.delete) > 0 { - changes = append(changes, fmt.Sprintf("DELETE: %s", strings.Join(d.delete, ", "))) - } - return strings.Join(changes, ", ") -} - func getNotebookDetails(path string) (isNotebook bool, typeOfNotebook string, err error) { isNotebook = false typeOfNotebook = ""