Skip to content

Commit 1c89112

Browse files
committed
docs: update readme's example
1 parent 0b71b17 commit 1c89112

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,42 @@ A simple yet complex method of storing large directory structures with duplicate
88

99
```rust
1010
// `input_dir` is the artifact, likely produced by a build system etc. This is what we want to "transmit".
11-
let input_dir = absolute(Path::new("./example_dir")).unwrap();
11+
let input_dir = absolute(Path::new("./example_dir"))?;
1212
// `repo_dir` is the Repo's contained directory, and should be hosted on a web server, as a directory, etc.
13-
let repo_dir = absolute(Path::new("./example_repo")).unwrap();
13+
let repo_dir = absolute(Path::new("./example_repo"))?;
1414
// `store_dir` is the local path for the local store, and will be where the Store is placed, and each artifact inside.
15-
let store_dir = absolute(Path::new("./example_store")).unwrap();
15+
let store_dir = absolute(Path::new("./example_store"))?;
16+
// `store_dir` is the local path for the local store, and will be where the Store is placed, and each artifact inside.
17+
let cache_path = absolute(Path::new("./example_cache"))?;
18+
19+
let store = Store {
20+
kind: RepoType::Local,
21+
cache_path,
22+
repo_path: repo_dir.to_string_lossy().to_string(),
23+
path: store_dir,
24+
};
1625

1726
// Create an example repo and a store, *locally*
18-
create_repo(repo_dir.as_path())?;
19-
create_store(&store_dir)?;
27+
let _ = create_repo(repo_dir.as_path());
28+
let _ = create_store(&store);
2029

2130
// Create an example artifact
22-
fs::create_dir_all(Path::new("./example_dir/nested_dir/super_nested_dir")).unwrap();
23-
fs::write("./example_dir/a", "Wow a file").unwrap();
24-
fs::write("./example_dir/nested_dir/b", "Wow another file, shocking.").unwrap();
31+
fs::create_dir_all(Path::new("./example_dir/nested_dir/super_nested_dir"))?;
32+
fs::write("./example_dir/a", "Wow a file")?;
33+
fs::write("./example_dir/nested_dir/b", "Wow another file, shocking.")?;
2534
fs::write(
2635
"./example_dir/nested_dir/super_nested_dir/c",
2736
"Nested nested nested file",
2837
)
2938
.unwrap();
3039

3140
// Compile the artifact into a manifest and chunks and store it
32-
build(
33-
input_dir.as_path(),
34-
repo_dir.as_path(),
35-
&"generic".to_string(),
36-
)
37-
.expect("Build Failure");
41+
build(&input_dir, &repo_dir, "generic")?;
3842

3943
// Install the resulting manifest into an artifact in the `store_dir`
40-
install_artifact(&"generic".to_string(), store_dir.as_path(), &repo_dir);
44+
install_artifact(&"generic".to_string(), &store)?;
45+
46+
Ok(())
4147
```
4248

4349
For further examples please check [the examples in the source tree.](https://github.com/TimelessOS/LCAS/tree/main/examples)

0 commit comments

Comments
 (0)