-
Notifications
You must be signed in to change notification settings - Fork 2
Lazy Loading
To prevent unnecessary use of bandwidth and disk space for files which will never be opened, our filesystem makes use of lazy loading.
When a new file is added to the filesystem, its path and data will be stored on different location keys in the DHT. On the other peers, the SyncFileEventListener will compare the paths on the DHT with the ones on the peer's local disk (in the mounted filesystem only). If it recognises an element which does not exist locally, it will create the path segment (dir, file, symlink) with contents set to zero bytes. As soon as the user wants to open the file, the OS will call open
to check the user access rights. In this method we hooked up the call to the DHT to load the content which will then lead to effectively inserting the content to the file. As this call to the DHT is only made if the file content's size is zero bytes long, we have to reload the content from the DHT in the read
call to ensure the latest changes have been downloaded to the peer.