Soushi-cloud (temporary name) is a Holochain application that allows users to store files on the Holochain network, in a file-system-like structure.
Inspired by the file-storage zome of the Holochain Open Dev community.
This DNA is responsible for storing files and their metadata. It's composed of only one zome, the File_System zome.
The path of the file is managed by the path system of Holochain.
The zome allows users to upload files to the Holochain network by chunking them into smaller parts and storing those chunks as entries.
The metadata associated with each file is also stored as an entry, and linked to the chunks via their entry hashes.
The zome provides various functions to create, read and update file metadata, retrieve file chunks, and search for files by path recursively.
There is actually no file recovery. When a file is updated or deleted, the previous entries of the file chunks is marked as deleted and a new version is created. When getting the file chunks, the zome will return the latest version of the file chunks.
FileMetadata
: stores metadata about a file, including its name, author, path, creation date, last modification date, size, file type, and a list of hashes for the file chunks entries that make up the file.FileChunk
: stores a chunk of a file as a serialized byte array.
PathFileSystem
: Typed path of the file system.PathToFileMetaData
: links a path to a original file_metadata entry.FileMetaDataUpdate
: links file_metadata entries to their previous versions when updated.
-
create_file(file_input: FileInput) -> ExternResult<FileOutput>
: Creates a new file by taking a file input containing the file's name, path, type, and content. The function first checks if the file already exists and if not, chunks the file into smaller parts and creates the metadata entry for the file. The function then returns a record containing the file metadata entry and a list of file chunk entries. -
get_file_chunks(file_metadata_hash: ActionHash) -> ExternResult<Vec<Record>>
: Retrieves a list of file chunk records associated with the specified file metadata entry hash. -
get_file_metadata(original_file_metadata_hash: ActionHash) -> ExternResult<Option<Record>>
: Retrieves the latest version of a file metadata entry for the specified hash. -
get_files_metadata_by_path_recursively(path_string: String) -> ExternResult<Vec<Record>>
: Retrieves all file metadata entries recursively from the specified directory path. -
update_file(update_file_metadata_input: UpdateFileMetadataInput) -> ExternResult<FileOutput>
: Updates a file by creating a new version of the file metadata entry and associating it with the previous version. The function then returns a record containing the new file metadata entry and a list of file chunk entries. -
delete_file(original_file_metadata_hash: ActionHash) -> ExternResult<Vec<ActionHash>>
: Deletes a file by marking the file metadata and its file chunks entries as deleted and returning a list of all the entry hashes that were deleted.
FileCreated
: emitted when a file is created.FileUpdated
: emitted when a file is updated.FileDeleted
: emitted when a file is deleted.
PREREQUISITE: set up the holochain development environment.
Enter the nix shell by running this in the root folder of the repository:
nix-shell
npm install
Run all the other instructions in this README from inside this nix-shell, otherwise they won't work.
npm start
This will create a network of 2 nodes connected to each other and their respective UIs. It will also bring up the Holochain Playground for advanced introspection of the conductors.
npm test
Create a custom network of nodes connected to each other and their respective UIs with:
AGENTS=3 npm run network
Substitute the "3" for the number of nodes that you want to bootstrap in your network. This will also bring up the Holochain Playground for advanced introspection of the conductors.
To package the web happ:
npm run package
You'll have the test-happ.webhapp
in workdir
. This is what you should distribute so that the Holochain Launcher can
install it.
You will also have its subcomponent test-happ.happ
in the same folder`.
This repository is using these tools:
- NPM Workspaces: npm v7's built-in monorepo capabilities.
- hc: Holochain CLI to easily manage Holochain development instances.
- @holochain/tryorama: test framework.
- @holochain/client: client library to connect to Holochain from the UI.
- @holochain-playground/cli: introspection tooling to understand what's going on in the Holochain nodes.