Skip to content

Commit 64d6127

Browse files
committed
libsql: add timestamp to atomic_write
1 parent 4575361 commit 64d6127

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libsql/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ libsql_replication = { version = "0.6", path = "../libsql-replication", optional
4444
async-stream = { version = "0.3.5", optional = true }
4545

4646
crc32fast = { version = "1", optional = true }
47+
chrono = { version = "0.4", optional = true }
4748

4849
[dev-dependencies]
4950
criterion = { version = "0.5", features = ["html_reports", "async", "async_futures", "async_tokio"] }
@@ -108,6 +109,7 @@ sync = [
108109
"dep:futures",
109110
"dep:serde_json",
110111
"dep:crc32fast",
112+
"dep:chrono"
111113
]
112114
hrana = [
113115
"parser",

libsql/src/sync.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{util::ConnectorService, Result};
33
use std::path::Path;
44

55
use bytes::Bytes;
6+
use chrono::Utc;
67
use hyper::Body;
78
use tokio::io::AsyncWriteExt as _;
89
use uuid::Uuid;
@@ -218,7 +219,8 @@ async fn atomic_write<P: AsRef<Path>>(path: P, data: &[u8]) -> Result<()> {
218219
// Create a temporary file in the same directory as the target file
219220
let directory = path.as_ref().parent().unwrap();
220221

221-
let temp_name = format!(".tmp.{}", Uuid::new_v4());
222+
let timestamp = Utc::now().format("%Y%m%d_%H%M%S");
223+
let temp_name = format!(".tmp.{}.{}", timestamp, Uuid::new_v4());
222224
let temp_path = directory.join(temp_name);
223225

224226
// Write data to temporary file

0 commit comments

Comments
 (0)