Skip to content

Commit d88089b

Browse files
committed
Rename gen_pkg_and_compile -> generate_package
1 parent e48369c commit d88089b

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/main.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn try_main() -> MainResult<i32> {
164164
let action = decide_action_for(&input, dependencies_from_args, prelude_items, &args)?;
165165
info!("action: {:?}", action);
166166

167-
gen_pkg_and_compile(&action)?;
167+
generate_package(&action)?;
168168

169169
// Once we're done, clean out old packages from the cache.
170170
let _defer_clear = {
@@ -244,20 +244,17 @@ fn clean_cache(max_age: u128) -> MainResult<()> {
244244
Ok(())
245245
}
246246

247-
// Generate and compile a package from the input.
248-
fn gen_pkg_and_compile(action: &InputAction) -> MainResult<()> {
249-
let pkg_path = &action.pkg_path;
250-
251-
let mani_str = &action.manifest;
252-
let script_str = &action.script;
253-
247+
// Generate a package from the input.
248+
fn generate_package(action: &InputAction) -> MainResult<()> {
254249
info!("creating pkg dir...");
255-
fs::create_dir_all(pkg_path)?;
250+
fs::create_dir_all(&action.pkg_path)?;
256251
let cleanup_dir: Defer<_, MainError> = Defer::new(|| {
257-
// DO NOT try deleting ANYTHING if we're not cleaning up inside our own cache. We *DO NOT* want to risk killing user files.
258252
if action.using_cache {
259-
info!("cleaning up cache directory {:?}", pkg_path);
260-
fs::remove_dir_all(pkg_path)?;
253+
// Only cleanup on failure if we are using the shared package
254+
// cache, and not when the user has specified the package path
255+
// (since that would risk removing user files).
256+
info!("cleaning up cache directory {:?}", &action.pkg_path);
257+
fs::remove_dir_all(&action.pkg_path)?;
261258
}
262259
Ok(())
263260
});
@@ -266,8 +263,8 @@ fn gen_pkg_and_compile(action: &InputAction) -> MainResult<()> {
266263
let mani_path = action.manifest_path();
267264
let script_path = action.script_path();
268265

269-
overwrite_file(&mani_path, mani_str)?;
270-
overwrite_file(&script_path, script_str)?;
266+
overwrite_file(&mani_path, &action.manifest)?;
267+
overwrite_file(&script_path, &action.script)?;
271268

272269
info!("disarming pkg dir cleanup...");
273270
cleanup_dir.disarm();

0 commit comments

Comments
 (0)