Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any plan to support syncing between devices or across clients (mac and Windows) #98

Open
cheerioskun opened this issue Sep 22, 2024 · 1 comment
Labels
question Further information is requested

Comments

@cheerioskun
Copy link

Summary

It would be very nice to have some sort of syncing support or the ability to set up the same ourselves with off the shelf tools like rclone. I am exploring how to do this and running into some issues like the path naming being different in windows vs mac. This causes replies to not be loaded when I've synced the folders even though the data/files are still there.

@cheerioskun cheerioskun added the question Further information is requested label Sep 22, 2024
@u9g
Copy link

u9g commented Sep 30, 2024

I've fixed the line endings problem in a way that allows me to share my pile folder in a dropbox across mac/windows using the patch below. Something to note is I only post things, I will not add replies or use any api keys, or anything else really, anywhere else that paths are saved need to have this patch applied to those path saving points too.

diff --git a/src/main/utils/pileIndex.js b/src/main/utils/pileIndex.js
index 5f9dcac..d0b3665 100644
--- a/src/main/utils/pileIndex.js
+++ b/src/main/utils/pileIndex.js
@@ -24,6 +24,13 @@ class PileIndex {
     return sortedMap;
   }
 
+  fixPathsInMap(map, seperator = path.sep) {
+    return new Map([...map.entries()].map(x => {
+      x[0] = x[0].replace(/[\\/]/g, seperator)
+      return x
+    }))
+  }
+
   resetIndex() {
     this.index.clear();
   }
@@ -43,7 +50,8 @@ class PileIndex {
       const data = fs.readFileSync(indexFilePath);
       const loadedIndex = new Map(JSON.parse(data));
       const sortedIndex = this.sortMap(loadedIndex);
-      this.index = sortedIndex;
+      const fixedIndex = this.fixPathsInMap(sortedIndex)
+      this.index = fixedIndex;
     } else {
       // init empty index
       this.save();
@@ -71,6 +79,7 @@ class PileIndex {
       });
 
       this.index = this.sortMap(this.index);
+      this.index = this.fixPathsInMap(this.index)
       return this.index;
     });
   };
@@ -203,6 +212,8 @@ class PileIndex {
     }
 
     const sortedIndex = this.sortMap(this.index);
+    // always save using windows style
+    const fixedIndex = this.fixPathsInMap(this.index, '\\')
     this.index = sortedIndex;
     const filePath = path.join(this.pilePath, this.fileName);
     const entries = this.index.entries();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants