Skip to content

Commit 94030b7

Browse files
refactor(SideCar): Improve cache serialization format and cleanup comments
- Updated `DownloadCache::Save` method to serialize JSON with tab-based indentation instead of default spaces, enhancing readability and consistency with project formatting standards - Removed redundant empty lines in `PlatformTarget` struct documentation - Deleted obsolete FIX comment about file copy operation since robust copy was previously implemented - Rebuilt Download.exe and SideCar.exe binaries as a result of source code changes These changes align with Land's focus on code quality and maintainability in the SideCar component, which handles VS Code extension host provisioning for the Cocoon ecosystem in Path A. The cache serialization improvement ensures consistent formatting while maintaining functional behavior.
1 parent 1ec3fd3 commit 94030b7

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

Source/Download.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ struct PlatformTarget {
4141
ArchiveExtension:String,
4242

4343
/// The official Tauri target triple for this platform (e.g.,
44-
///
45-
///
4644
/// "x86_64-pc-windows-msvc").
4745
TauriTargetTriple:String,
4846
}
@@ -141,12 +139,23 @@ impl DownloadCache {
141139
}
142140

143141
/// Saves the current state of the cache to the `Cache.json` file.
144-
/// The JSON is pretty-printed for readability.
142+
/// The JSON is pretty-printed with tabs for indentation.
145143
fn Save(&self, CachePath:&Path) -> Result<()> {
146-
let File =
147-
File::create(CachePath).with_context(|| format!("Failed to create cache file at {:?}", CachePath))?;
144+
// Create an in-memory buffer to write the serialized JSON to.
145+
let mut Buffer = Vec::new();
146+
147+
// Create a formatter that uses a tab character for indentation.
148+
let Formatter = serde_json::ser::PrettyFormatter::with_indent(b"\t");
149+
150+
// Create a serializer with our custom formatter.
151+
let mut Serializer = serde_json::Serializer::with_formatter(&mut Buffer, Formatter);
152+
153+
// Serialize the `DownloadCache` data into the buffer.
154+
self.serialize(&mut Serializer)?;
148155

149-
serde_json::to_writer_pretty(File, self).with_context(|| "Failed to serialize and write to cache file.")?;
156+
// Write the buffer's contents to the actual file on disk.
157+
fs::write(CachePath, &Buffer)
158+
.with_context(|| format!("Failed to write tab-formatted cache to {:?}", CachePath))?;
150159

151160
Ok(())
152161
}
@@ -461,7 +470,6 @@ async fn ProcessDownloadTask(Task:DownloadTask, Client:Client, Cache:Arc<Mutex<D
461470

462471
info!(" Installing to: {:?}", Task.DestinationDirectory);
463472

464-
// *** FIX: Use a robust copy operation for the contents. ***
465473
// This is the most reliable method for populating a directory, especially
466474
// across drives.
467475
let mut Options = FsExtraCopyOptions::new();

Target/debug/Download.exe

-1.5 KB
Binary file not shown.

Target/debug/SideCar.exe

-1.5 KB
Binary file not shown.

Target/release/Download.exe

27 KB
Binary file not shown.

Target/release/SideCar.exe

27 KB
Binary file not shown.

0 commit comments

Comments
 (0)