Stack r1: #2745: the portable write probe writes a byte; the README names the profile's app.ron to copy

This commit is contained in:
Tanish Manku
2026-11-20 08:18:35 -07:00
parent 8ea4c908e2
commit 2c8b8f438c
2 changed files with 10 additions and 3 deletions
+3 -1
View File
@@ -200,7 +200,9 @@ settings are not automatically copied into the portable directory.
Before switching an existing Windows installation to portable mode, close CADCraft,
back up `%APPDATA%\CADCraft`, and copy the settings you want to retain into
`CADCraftData`. Include the `autosave` folder if you need to recover unsaved drawings.
`CADCraftData`. Include the `autosave` folder if you need to recover unsaved drawings. The
preferences and window state are kept apart, in `%APPDATA%\ai.storyteller.cadcraft\data\app.ron`:
copy that file to `CADCraftData\app.ron` to keep them.
Updating a portable ZIP, including through the updater, can restore `portable.txt`;
set `CADCRAFT_CONFIG_DIR` to your existing profile folder to keep using it across updates.
+7 -2
View File
@@ -1,5 +1,6 @@
//! Windows portable ZIP settings, selected by a marker beside the executable.
use std::io::Write as _;
use std::path::{Path, PathBuf};
/// A marker must be a file. Prove the data folder is writable before selecting it.
@@ -10,9 +11,13 @@ pub(crate) fn directory_in(exe_dir: &Path) -> std::io::Result<Option<PathBuf>> {
let data = exe_dir.join("CADCraftData");
std::fs::create_dir_all(&data)?;
let probe = data.join(format!(".portable-write-test-{}", std::process::id()));
let file = std::fs::OpenOptions::new().write(true).create_new(true).open(&probe)?;
// A byte, not just an empty file: a full drive can still make the file and refuse its data.
let mut file = std::fs::OpenOptions::new().write(true).create_new(true).open(&probe)?;
let written = file.write_all(&[0]).and_then(|()| file.sync_all());
drop(file);
std::fs::remove_file(probe)?;
let removed = std::fs::remove_file(&probe);
written?;
removed?;
Ok(Some(data))
}