MCPcopy Create free account
hub / github.com/GCWing/BitFun / get_file_editor_sync_hash

Function get_file_editor_sync_hash

src/apps/desktop/src/api/commands.rs:2909–2948  ·  view source on GitHub ↗
(
    state: State<'_, AppState>,
    request: GetFileMetadataRequest,
)

Source from the content-addressed store, hash-verified

2907/// external-sync check, so the UI can compare with a local hash without transferring file contents.
2908#[tauri::command]
2909pub async fn get_file_editor_sync_hash(
2910 state: State<'_, AppState>,
2911 request: GetFileMetadataRequest,
2912) -> Result<serde_json::Value, String> {
2913 match resolve_desktop_path_target(&state, &request.path, None).await? {
2914 DesktopPathTarget::Remote {
2915 requested_path,
2916 entry,
2917 } => {
2918 let remote_fs = state
2919 .get_remote_file_service_async()
2920 .await
2921 .map_err(|e| format!("Remote file service not available: {}", e))?;
2922 let bytes = remote_fs
2923 .read_file(&entry.connection_id, &requested_path)
2924 .await
2925 .map_err(|e| format!("Failed to read remote file: {}", e))?;
2926 let hash = state
2927 .filesystem_service
2928 .editor_sync_sha256_hex_from_raw_bytes(&bytes);
2929 Ok(serde_json::json!({
2930 "path": requested_path,
2931 "hash": hash,
2932 "is_remote": true
2933 }))
2934 }
2935 DesktopPathTarget::Local { resolved_path, .. } => {
2936 let hash = state
2937 .filesystem_service
2938 .editor_sync_content_sha256_hex(&resolved_path.to_string_lossy())
2939 .await
2940 .map_err(|e| e.to_string())?;
2941
2942 Ok(serde_json::json!({
2943 "path": request.path,
2944 "hash": hash
2945 }))
2946 }
2947 }
2948}
2949
2950#[tauri::command]
2951pub async fn rename_file(

Callers

nothing calls this directly

Tested by

no test coverage detected