summaryrefslogtreecommitdiff
path: root/crates/vcs_data
diff options
context:
space:
mode:
Diffstat (limited to 'crates/vcs_data')
-rw-r--r--crates/vcs_data/src/constants.rs15
-rw-r--r--crates/vcs_data/src/data/sheet.rs21
-rw-r--r--crates/vcs_data/src/data/vault.rs49
-rw-r--r--crates/vcs_data/src/data/vault/sheets.rs1
-rw-r--r--crates/vcs_data/src/data/vault/virtual_file.rs2
5 files changed, 33 insertions, 55 deletions
diff --git a/crates/vcs_data/src/constants.rs b/crates/vcs_data/src/constants.rs
index 55662e7..e835482 100644
--- a/crates/vcs_data/src/constants.rs
+++ b/crates/vcs_data/src/constants.rs
@@ -48,17 +48,20 @@ pub const CLIENT_FOLDER_WORKSPACE_ROOT_NAME: &str = ".jv";
pub const CLIENT_FILE_WORKSPACE: &str = "./.jv/workspace.toml";
// Client - Latest Information
-pub const CLIENT_FILE_LATEST_INFO: &str = "./.jv/latest.json";
+pub const CLIENT_FILE_LATEST_INFO: &str = "./.jv/.latest.json";
-// Client - Sheets
-pub const CLIENT_FILE_SHEET_COPY: &str = "./.jv/sheets/{sheet_name}.copy.json";
+// Client - Local
+pub const CLIENT_PATH_LOCAL_DRAFT: &str = "./.jv/drafts/{account}/{sheet_name}/";
+pub const CLIENT_FILE_LOCAL_SHEET: &str = "./.jv/sheets/{account}/{sheet_name}_local.toml";
+pub const CLIENT_FILE_CACHED_SHEET: &str = "./.jv/sheets/{account}/{sheet_name}.toml";
+pub const CLIENT_FILE_MEMBER_HELD: &str = "./.jv/helds/{account}_held.toml";
-// Client - Local Draft
-pub const CLIENT_PATH_LOCAL_DRAFT: &str = "./.jv/drafts/{account}_{sheet_name}/";
+pub const CLIENT_FILE_LOCAL_SHEET_NOSET: &str = "./.jv/.temp/wrong_local_sheet.toml";
+pub const CLIENT_FILE_MEMBER_HELD_NOSET: &str = "./.jv/.temp/wrong_member_held.toml";
// Client - Other
pub const CLIENT_FILE_IGNOREFILES: &str = "IGNORE_RULES.toml";
-pub const CLIENT_FILE_README: &str = "./README.md";
+pub const CLIENT_FILE_TODOLIST: &str = "./TODO.md";
// -------------------------------------------------------------------------------------
diff --git a/crates/vcs_data/src/data/sheet.rs b/crates/vcs_data/src/data/sheet.rs
index 69dc27d..09271d5 100644
--- a/crates/vcs_data/src/data/sheet.rs
+++ b/crates/vcs_data/src/data/sheet.rs
@@ -50,6 +50,9 @@ pub struct Sheet<'a> {
#[derive(Default, Serialize, Deserialize, ConfigFile, Clone)]
pub struct SheetData {
+ /// The write count of the current sheet
+ pub(crate) write_count: i32,
+
/// The holder of the current sheet, who has full operation rights to the sheet mapping
pub(crate) holder: Option<MemberId>,
@@ -89,6 +92,11 @@ impl<'a> Sheet<'a> {
&self.data.mapping
}
+ /// Get the write count of this sheet
+ pub fn write_count(&self) -> i32 {
+ self.data.write_count
+ }
+
/// Forget the holder of this sheet
pub fn forget_holder(&mut self) {
self.data.holder = None;
@@ -263,7 +271,11 @@ impl<'a> Sheet<'a> {
/// Why not use a reference?
/// Because I don't want a second instance of the sheet to be kept in memory.
/// If needed, please deserialize and reload it.
- pub async fn persist(self) -> Result<(), std::io::Error> {
+ pub async fn persist(mut self) -> Result<(), std::io::Error> {
+ self.data.write_count += 1;
+ if self.data.write_count > i32::MAX {
+ self.data.write_count = 0;
+ }
SheetData::write_to(&self.data, self.sheet_path()).await
}
@@ -384,3 +396,10 @@ impl<'a> Sheet<'a> {
self.data
}
}
+
+impl SheetData {
+ /// Get the write count of this sheet data
+ pub fn write_count(&self) -> i32 {
+ self.write_count
+ }
+}
diff --git a/crates/vcs_data/src/data/vault.rs b/crates/vcs_data/src/data/vault.rs
index efb4eec..fedebb3 100644
--- a/crates/vcs_data/src/data/vault.rs
+++ b/crates/vcs_data/src/data/vault.rs
@@ -6,6 +6,7 @@ use std::{
};
use cfg_file::config::ConfigFile;
+use vcs_docs::docs::READMES_VAULT_README;
use crate::{
constants::{
@@ -94,53 +95,7 @@ impl Vault {
.await?;
// Final, generate README.md
- let readme_content = format!(
- "\
-# JustEnoughVCS Server Setup
-
-This directory contains the server configuration and data for `JustEnoughVCS`.
-
-## User Authentication
-To allow users to connect to this server, place their public keys in the `{}` directory.
-Each public key file should be named `{{member_id}}.pem` (e.g., `juliet.pem`), and contain the user's public key in PEM format.
-
-**ECDSA:**
-```bash
-openssl genpkey -algorithm ed25519 -out your_name_private.pem
-openssl pkey -in your_name_private.pem -pubout -out your_name.pem
-```
-
-**RSA:**
-```bash
-openssl genpkey -algorithm RSA -out your_name_private.pem -pkeyopt rsa_keygen_bits:2048
-openssl pkey -in your_name_private.pem -pubout -out your_name.pem
-```
-
-**DSA:**
-```bash
-openssl genpkey -algorithm DSA -out your_name_private.pem -pkeyopt dsa_paramgen_bits:2048
-openssl pkey -in your_name_private.pem -pubout -out your_name.pem
-```
-
-Place only the `your_name.pem` file in the server's `./key/` directory, renamed to match the user's member ID.
-
-## File Storage
-All version-controlled files (Virtual File) are stored in the `{}` directory.
-
-## License
-This software is distributed under the MIT License. For complete license details, please see the main repository homepage.
-
-## Support
-Repository: `https://github.com/JustEnoughVCS/VersionControl`
-Please report any issues or questions on the GitHub issue tracker.
-
-## Thanks :)
-Thank you for using `JustEnoughVCS!`
- ",
- SERVER_PATH_MEMBER_PUB, SERVER_PATH_VF_ROOT
- )
- .trim()
- .to_string();
+ let readme_content = READMES_VAULT_README;
fs::write(vault_path.join(SERVER_FILE_README), readme_content)?;
Ok(())
diff --git a/crates/vcs_data/src/data/vault/sheets.rs b/crates/vcs_data/src/data/vault/sheets.rs
index 1407350..ba021b5 100644
--- a/crates/vcs_data/src/data/vault/sheets.rs
+++ b/crates/vcs_data/src/data/vault/sheets.rs
@@ -133,6 +133,7 @@ impl Vault {
holder: Some(holder.clone()),
inputs: Vec::new(),
mapping: HashMap::new(),
+ write_count: 0,
};
SheetData::write_to(&sheet_data, sheet_file_path).await?;
diff --git a/crates/vcs_data/src/data/vault/virtual_file.rs b/crates/vcs_data/src/data/vault/virtual_file.rs
index fe83594..221766f 100644
--- a/crates/vcs_data/src/data/vault/virtual_file.rs
+++ b/crates/vcs_data/src/data/vault/virtual_file.rs
@@ -51,7 +51,7 @@ pub struct VirtualFileMeta {
histories: Vec<VirtualFileVersion>,
}
-#[derive(Default, Clone, Serialize, Deserialize)]
+#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct VirtualFileVersionDescription {
/// The member who created this version
pub creator: MemberId,