I’ve been putting together a prototype duplicacy fuse file-system (don’t get too excited, it’s mostly unusable) using https://github.com/billziss-gh/cgofuse
It’s to the stage where I can mount a repository and list all snapshot ids on the specified storage and the browse down into each revision and the directory structure underneath.
Opening files is not yet implemented and any operations that make changes are deliberately not implemented so it’s basically read only.
Where I’ve got concerns is how to handle the retrieving file and directory data via the following fuse/file system operations that are needed to satisfy the fuse interface.
Readdir: getting a list of files/dirs in a particular path
Getattr: get the attributes of a particular path (ie stat info)
I’m currently doing this using the following:
manager := duplicacy.CreateBackupManager(snapshotid, ...)
manager.SetupSnapshotCache(...)
snap := manager.SnapshotManager.DownloadSnapshot(snapshotid, revision)
manager.SnapshotManager.DownloadSnapshotContents(snap, nil, true)
At that point I cache the contents of the “snap” slice for later, then loop over the “snap” slice to find the entries for the current path.
This seems incredibly inefficient as I’ve now got info for every file in the snapshot in memory for potentially listing the contents of an empty directory.
Then for a “Getattr” operation, which is to retrieve the file info for a single file/dir it’s a case of potentially traversing the entire “snap” slice to return some basic stat info like file size, modification time, mode etc…
I’ve got a background goroutine that removes/deletes cached data to keep memory use down, but its not unusual for my “duplicacy-fuse” process to eat up almost a GB of RAM by just browsing two or three revisions from one snapshot id on the storage.
Is there a better way to handle this?
Some way to only retrieve info for a particular path in a backup?
Currently the repo I’m working on is set to private as to be honest I’m not sure I want the world to see what is pretty terrible code…but if it helps I can share the URL.