Skip to content

Commit 92a5a11

Browse files
author
Zheming Li
committed
Fix spec path in delete
1 parent d87020c commit 92a5a11

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

oci_spec/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@ pub struct Spec {
609609
impl Spec {
610610
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self> {
611611
let path = path.as_ref();
612-
let file = File::open(path).with_context(|| format!("failed to open {:?}", path))?;
612+
let file =
613+
File::open(path).with_context(|| format!("load spec: failed to open {:?}", path))?;
613614
let spec: Spec = serde_json::from_reader(&file)?;
614615
Ok(spec)
615616
}

src/delete.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::fs;
2-
use std::path::Path;
32
use std::path::PathBuf;
43

54
use anyhow::{bail, Result};
@@ -42,11 +41,7 @@ impl Delete {
4241
log::debug!("container status: {:?}", container.status());
4342
if container.can_delete() {
4443
if container.root.exists() {
45-
nix::unistd::chdir(&PathBuf::from(&container.state.bundle))?;
46-
let config_absolute_path = &PathBuf::from(&container.state.bundle)
47-
.join(Path::new("config.json"))
48-
.to_string_lossy()
49-
.to_string();
44+
let config_absolute_path = container.root.join("config.json");
5045
log::debug!("load spec from {:?}", config_absolute_path);
5146
let spec = oci_spec::Spec::load(config_absolute_path)?;
5247
log::debug!("spec: {:?}", spec);

0 commit comments

Comments
 (0)