Is there any plan to support syncing between devices or across clients (mac and Windows)
Opened this issue · 1 comments
cheerioskun commented
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.
u9g commented
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();