diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-12-15 21:27:11 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-12-15 21:27:11 +0800 |
| commit | 245236ce3a6c07962e345cb33fb6c5f6ce6e221b (patch) | |
| tree | f9270ebbe83ec41988911e75002005eb3f3ecdce /crates/vcs_data/src | |
| parent | ead13b7fe78e8c81478d4c8a4bf20ad1920e380a (diff) | |
Remove unnecessary edit rights check in sheet mapping
The permission check for virtual file edit rights when adding a sheet
mapping was meaningless since the mapping operation doesn't actually
modify the virtual file content. The mapping can now be added regardless
of the member's edit rights to the virtual file.
Diffstat (limited to 'crates/vcs_data/src')
| -rw-r--r-- | crates/vcs_data/src/data/sheet.rs | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/crates/vcs_data/src/data/sheet.rs b/crates/vcs_data/src/data/sheet.rs index 900331d..7643887 100644 --- a/crates/vcs_data/src/data/sheet.rs +++ b/crates/vcs_data/src/data/sheet.rs @@ -192,9 +192,7 @@ impl<'a> Sheet<'a> { /// This operation performs safety checks to ensure the member has the right to add the mapping: /// 1. The sheet must have a holder (member) to perform this operation /// 2. If the virtual file ID doesn't exist in the vault, the mapping is added directly - /// 3. If the virtual file exists, check if the member has edit rights to the virtual file - /// 4. If member has edit rights, the mapping is not allowed to be modified and returns an error - /// 5. If member doesn't have edit rights, the mapping is allowed (member is giving up the file) + /// 3. If the virtual file exists, the mapping is added regardless of member edit rights /// /// Note: Full validation adds overhead - avoid frequent calls pub async fn add_mapping( @@ -217,44 +215,22 @@ impl<'a> Sheet<'a> { } // Check if the sheet has a holder - let Some(holder) = self.holder() else { + let Some(_) = self.holder() else { return Err(std::io::Error::new( std::io::ErrorKind::PermissionDenied, "This sheet has no holder", )); }; - // Check if the holder has edit rights to the virtual file - match self - .vault_reference - .has_virtual_file_edit_right(holder, &virtual_file_id) - .await - { - Ok(true) => { - // Holder has edit rights, add the mapping (member has permission to modify the file) - self.data.mapping.insert( - sheet_path, - SheetMappingMetadata { - id: virtual_file_id, - version, - }, - ); - Ok(()) - } - Ok(false) => { - // Holder doesn't have edit rights, don't allow modifying the mapping - Err(std::io::Error::new( - std::io::ErrorKind::PermissionDenied, - "Member doesn't have edit rights to the virtual file, cannot modify mapping", - )) - } - Err(_) => { - // Error checking rights, don't allow modifying the mapping - Err(std::io::Error::other( - "Failed to check virtual file edit rights", - )) - } - } + self.data.mapping.insert( + sheet_path, + SheetMappingMetadata { + id: virtual_file_id, + version, + }, + ); + + Ok(()) } /// Remove a mapping entry from the sheet |
