Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
raincity committed Nov 21, 2023
1 parent 5c056d5 commit be7861d
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 5 deletions.
136 changes: 134 additions & 2 deletions .test-replica/data/run2-file.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,23 @@
]
},
{
"key": "BP3v7msl38fDdFDG",
"key": "uA6q7msouXoFbf1H",
"path": "./tests/file1.txt",
"hash": "",
"len": 186,
"modified": 1700331937339576,
"last_saved": "2023-11-21T02:01:35.088522377",
"written_to": [
"tback/./tests/file1.txt"
]
},
{
"key": "H7fh7msouXoFt493",
"path": "./tests/big-file.pdf",
"hash": "",
"len": 474707,
"modified": 1699990650530503,
"last_saved": "2023-11-21T01:02:37.556382986",
"last_saved": "2023-11-21T02:01:35.089120465",
"written_to": [
"tback/./tests/big-file.pdf"
]
Expand All @@ -65,6 +76,17 @@
"tback/./tests/.config/file1.txt"
]
},
{
"key": "BP3v7msl38fDdFDG",
"path": "./tests/big-file.pdf",
"hash": "",
"len": 474707,
"modified": 1699990650530503,
"last_saved": "2023-11-21T01:02:37.556382986",
"written_to": [
"tback/./tests/big-file.pdf"
]
},
{
"key": "zPKK7msl0dQLitM5",
"path": "./tests/file1.txt",
Expand Down Expand Up @@ -109,6 +131,28 @@
"tback/./tests/.config/file2.txt"
]
},
{
"key": "0gBH7msouXoFnkzK",
"path": "./tests/file2.txt",
"hash": "",
"len": 19,
"modified": 1700331937339576,
"last_saved": "2023-11-21T02:01:35.088654972",
"written_to": [
"tback/./tests/file2.txt"
]
},
{
"key": "0NE97mspHtaliAP1",
"path": "./tests/file1.txt",
"hash": "",
"len": 186,
"modified": 1700331937339576,
"last_saved": "2023-11-21T02:07:20.135639811",
"written_to": [
"tback/./tests/file1.txt"
]
},
{
"key": "pNjN7msl0dQMmU6K",
"path": "./tests/.config/file2.txt",
Expand All @@ -120,6 +164,17 @@
"tback/./tests/.config/file2.txt"
]
},
{
"key": "06gK7mspHtam6vC0",
"path": "./tests/changed-file.txt",
"hash": "",
"len": 57,
"modified": 1700532440130046,
"last_saved": "2023-11-21T02:07:20.136257746",
"written_to": [
"tback/./tests/changed-file.txt"
]
},
{
"key": "LOqI7msl0dQMfjcK",
"path": "./tests/.config/file1.txt",
Expand All @@ -131,6 +186,28 @@
"tback/./tests/.config/file1.txt"
]
},
{
"key": "qKhx7mspHtamakty",
"path": "./tests/.config/file1.txt",
"hash": "",
"len": 186,
"modified": 1700331937339576,
"last_saved": "2023-11-21T02:07:20.136379799",
"written_to": [
"tback/./tests/.config/file1.txt"
]
},
{
"key": "bSZJ7msouXoFzgVd",
"path": "./tests/changed-file.txt",
"hash": "",
"len": 57,
"modified": 1700532095083149,
"last_saved": "2023-11-21T02:01:35.089227356",
"written_to": [
"tback/./tests/changed-file.txt"
]
},
{
"key": "ccwK7mskxKz70F0S",
"path": "./tests/file1.txt",
Expand Down Expand Up @@ -164,6 +241,17 @@
"tback/./tests/file2.txt"
]
},
{
"key": "MCK47mspHtamiVP7",
"path": "./tests/.config/file2.txt",
"hash": "",
"len": 19,
"modified": 1700331937339576,
"last_saved": "2023-11-21T02:07:20.136466845",
"written_to": [
"tback/./tests/.config/file2.txt"
]
},
{
"key": "QSdQ7mskxKz7LsHS",
"path": "./tests/file2.txt",
Expand Down Expand Up @@ -257,6 +345,17 @@
"tback/./tests/.config/file1.txt"
]
},
{
"key": "a2tw7mspHtaluIPy",
"path": "./tests/file2.txt",
"hash": "",
"len": 19,
"modified": 1700331937339576,
"last_saved": "2023-11-21T02:07:20.135749002",
"written_to": [
"tback/./tests/file2.txt"
]
},
{
"key": "1jiG7msl38fDiLRx",
"path": "./tests/changed-file.txt",
Expand All @@ -277,6 +376,17 @@
"last_saved": null,
"written_to": []
},
{
"key": "45eV7msouXoGTnuY",
"path": "./tests/.config/file1.txt",
"hash": "",
"len": 186,
"modified": 1700331937339576,
"last_saved": "2023-11-21T02:01:35.089400847",
"written_to": [
"tback/./tests/.config/file1.txt"
]
},
{
"key": "GJYg7mskxeejxMHM",
"path": "./tests/changed-file.txt",
Expand All @@ -299,6 +409,28 @@
"tback/./tests/changed-file.txt"
]
},
{
"key": "JBIS7msouXoGZ0lI",
"path": "./tests/.config/file2.txt",
"hash": "",
"len": 19,
"modified": 1700331937339576,
"last_saved": "2023-11-21T02:01:35.089504300",
"written_to": [
"tback/./tests/.config/file2.txt"
]
},
{
"key": "ZuvO7mspHtam01v9",
"path": "./tests/big-file.pdf",
"hash": "",
"len": 474707,
"modified": 1699990650530503,
"last_saved": "2023-11-21T02:07:20.136161875",
"written_to": [
"tback/./tests/big-file.pdf"
]
},
{
"key": "XuZ57msaerQLJtwC",
"path": "tback/./tests/file1.txt",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "replica"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
authors = ["[email protected]"]
rust-version = "1.70"
Expand Down
2 changes: 2 additions & 0 deletions src/kv_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ impl KeyValueStore {
/// save the kv to file
pub fn savedb(&mut self, filename: &str) -> Result<()> {
info!("save the k/v models as a list to file: {}", filename);
// ok, first copy the current to a time-stamped replica.

let list: Vec<FileModel> = self.db.clone().into_values().collect();
let json = serde_json::to_string_pretty(&list).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion tests/changed-file.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
the time: Instant { tv_sec: 3757088, tv_nsec: 768845687 }
the time: Instant { tv_sec: 3760971, tv_nsec: 365143245 }

0 comments on commit be7861d

Please sign in to comment.