obsidian-livesync icon indicating copy to clipboard operation
obsidian-livesync copied to clipboard

[Feature Request] Sync Attachment on demand and clear them periodically to save up disk on edge device

Open qlibp opened this issue 1 year ago • 2 comments

Scenario: It's nice to sync all .md files across all devices, but it's not quite a good idea to sync all attachments across all devices, especially on mobile side. For example, I just wanna view some of the pdfs occasionally, not all the pdfs should be synced to mobile side. I would like to sync/download the attachments when it's needed.

Possible Feature:

  • When opening a pdf/some other attachments(some event occurs), livesync client check if the attachment exist on remote couch db(either make a communication/save some meta info about the file on client side to indicate), if so, sync the file from couch db.
  • When editing the attachments, livesync sync as usual.
  • After the attachments are not required for a period of time/disk usage is not enough, it gets deleted(maybe leaving out some meta info data there to indicate that remote couch db has this file)

Maybe this feature could be named as a cache feature.

qlibp avatar May 09 '24 13:05 qlibp

Thank you for the request! I think this might be a useful feature. However, we have a few things to solve.

  1. Possibly, we should have a stub file to handle the existence. Otherwise, we cannot fetch that again if the file is not referenced from anywhere.
  2. Self-hosted LiveSync always handles the file events, but cannot intercept them. So, we should hook the file opening or create events. This possibly causes some unexpected behaviour (i.e., clicking [[a.png]] without real a.png makes a.png.md).
  3. From the point of view of other plugins, it may be a bit difficult to interpret.
  4. We cannot rebuild the database as in the past.

However, indeed it might be a useful feature (especially at the initial setup). I hope to think about it more deeply in the time that I can focus on it.

vrtmrz avatar Jul 01 '24 08:07 vrtmrz

For now, I use pdf++ plugin's dummy pdf feature to handle pdf file. Maybe it could be served as a reference.

qlibp avatar Jul 09 '24 10:07 qlibp