# FairOS improvement proposals ###### tags: `fairos`, `fuse` ### Milestones - [ ] Modes - [ ] Syncing and listing directory content - [ ] Renaming files and folders - [ ] Account improvements - [ ] FUSE ## could be merged with https://hackmd.io/@crtahlin/r1gaxPLJj ? > [name=Sabyasachi Patra] Not required as the queue is implemented globally. i.e the server/module will use a single queue for all operations. #### Modes With recent changes fairOS can be used as dependency, making it capable of running on frontend apps for a single user perspective. Keeping this is mind we can have two different modes to run fairOS, **Server** and **Solo**. **Server** mode is the default mode where fairSO is running an http server where multiple users access it. **Solo** mode can be used when we intent to use fairOS on fronend apps for a single user. This mode will allow user to use more CPU for syncing and listing files. We also plan to introduce a **Dev** mode where we will start a mock bee and ENS client which can be used for development. > [name=Sabyasachi Patra] This is implemented #### Syncing and Listing content In the currrent implementation of syncing pod, directories and files, we sync one item at a time. So we get metadata of the items one by one making the sync time longer. To reduce it, we will introduce a queue to process data. This means we will put items in the queue and start *n* number of workers to get item metadata. Depending on the mode, *n* will change. Therefore, while running on **Server** mode, we will assign less number workers to each user. Similarly in **Solo** mode we assign more workers, as the fairOS instance will be running for a single user. fairOS has a directory object that keeps the metadata of all dirs and files cached after it is loaded from bee. So it makes sence to add the *SyncManager* to the Directory class. We can use https://github.com/plexsysio/taskmanager for `SyncManager`. `SyncManager` will work on `SyncTasks` roughly described below ```go=16 type SyncTask struct { d *Directory path string } func NewSyncTask(d *Directory, path string) *SyncTask { return &{ d: d, path: path, } } func (st *SyncTask) Execute() { st.d.file.LoadFileMeta(st.path) } ``` In [SyncDirectory](https://github.com/fairDataSociety/fairOS-dfs/blob/5d46a2a3b3ec90549780fde62366fae89383d79a/pkg/dir/sync.go#L26) we will create `SyncTask` for each file and push them into `SyncManager` and wait for all the files to sync, then return. This will speed up the syncing process as the loading is concurrent. #### Pagination In `directory ls`, rather than syncing all items in the directory, we will allow pagination. This will be good for UX. > [name=Sabyasachi Patra] Implemented #### Renaming files and folders - **File Renaming** : We can easily achive this by only changing the file metadata and the parent metadata. - **Directory renaming** : This will be a bit tricky but easy. We will have to update all the children metadata then update the directory metadata and the parent metadata. #### Account improvements - **Password reset** : With the new ENS based login system we can allow this very easily. We will ask for the mnemonic, old password, new password. ##### Step 1: Login with the old password and get the SOC. ##### Step 2: Decrypt the seed match with the mnemonic. ##### Step 3: Encrypt the seed with new password and upload. ##### Step 4: Update the old SOC value with garbage. - Do we like the idea of sub accounts??? We can have that multiple ways. Such as `asabya.rootaccount` or `rootaccount+asabya`... > [name=Sabyasachi Patra] Implemented #### FUSE With reference to the meeting with alok about bee-afs... we cannot use that directly with fairOS as both have some fundamental differences on how file is stored on bee. That being said, fairOS can take reference from the fuse implementation and make a fairOS compatible module. To have the basic implementation of fuse, fairOS lacks two basic things, `Renaming` and `Creating and updating same file`. ###### Some basic point about the fuse implementation - [ ] create a different cli application - [ ] use fairOS as a module - [ ] make some king of cache to create and upload files and store metadata - [ ] mount single pod, not the whole account - [ ] make metadata syncer to sync content in background ##### Some code more reference ``` type fdfs struct { fuse.FileSystemBase api *api.DfsAPI } ... ... func NewFdfs(username, password, pod string) *fdfs { api := dfs.NewDfsAPI() user := api.LoginUserV2(username, password, "") pod := api.OpenPod(pod, password, user.GetSessionId()) return &fdfs{ ... } } func main() { f := NewFdfs(username, password, pod) host := fuse.NewFileSystemHost(f) host.Mount("", <MOUNT_POINT>) } ``` ## TODO Research - API standards - CRDT (what is this ?)