diff --git a/media-converter/src/audioconv/imp.rs b/media-converter/src/audioconv/imp.rs index d22a8f0c..d494b84c 100644 --- a/media-converter/src/audioconv/imp.rs +++ b/media-converter/src/audioconv/imp.rs @@ -211,7 +211,7 @@ impl AudioConverterDumpFozdb { return self; } - match fossilize::StreamArchive::new(&dump_file_path, OpenOptions::new().write(true).read(true).create(create), AUDIOCONV_FOZ_NUM_TAGS) { + match fossilize::StreamArchive::new(&dump_file_path, OpenOptions::new().write(true).read(true).create(create), false /* read-only? */, AUDIOCONV_FOZ_NUM_TAGS) { Ok(newdb) => { self.fozdb = Some(newdb); }, @@ -237,7 +237,7 @@ impl AudioConverterDumpFozdb { } if let Some(fozdb) = &mut self.open(false).fozdb { if let Ok(read_fozdb_path) = std::env::var("MEDIACONV_AUDIO_TRANSCODED_FILE") { - if let Ok(read_fozdb) = fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), AUDIOCONV_FOZ_NUM_TAGS) { + if let Ok(read_fozdb) = fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), true /* read-only? */, AUDIOCONV_FOZ_NUM_TAGS) { let mut chunks_to_discard = HashSet::<(u32, u128)>::new(); let mut chunks_to_keep = HashSet::<(u32, u128)>::new(); @@ -559,7 +559,7 @@ impl AudioConvState { loggable_error!(CAT, "MEDIACONV_AUDIO_TRANSCODED_FILE is not set!") })?; - let read_fozdb = match fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), AUDIOCONV_FOZ_NUM_TAGS) { + let read_fozdb = match fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), true /* read-only? */, AUDIOCONV_FOZ_NUM_TAGS) { Ok(s) => Some(s), Err(_) => None, }; diff --git a/media-converter/src/fossilize.rs b/media-converter/src/fossilize.rs index f9ac1f95..658399a6 100644 --- a/media-converter/src/fossilize.rs +++ b/media-converter/src/fossilize.rs @@ -197,6 +197,7 @@ impl PayloadEntry { pub struct StreamArchive { file: fs::File, + read_only: bool, seen_blobs: Vec>, @@ -210,7 +211,7 @@ pub enum CRCCheck { impl StreamArchive { - pub fn new>(filename: P, fileopts: &OpenOptions, num_tags: usize) -> Result { + pub fn new>(filename: P, fileopts: &OpenOptions, read_only: bool, num_tags: usize) -> Result { let file = fileopts.open(filename)?; @@ -221,6 +222,7 @@ impl StreamArchive { let mut ret = Self { file, + read_only, seen_blobs, write_pos: 0, }; @@ -272,8 +274,7 @@ impl StreamArchive { match res { Ok(p) => { self.write_pos = p; - if tag >= self.seen_blobs.len() && - self.file.metadata()?.permissions().readonly() { + if tag >= self.seen_blobs.len() && self.read_only { /* ignore unknown tags for read-only DBs, otherwise panic */ continue; } diff --git a/media-converter/src/videoconv/imp.rs b/media-converter/src/videoconv/imp.rs index e9bf0f5a..95556d2a 100644 --- a/media-converter/src/videoconv/imp.rs +++ b/media-converter/src/videoconv/imp.rs @@ -138,7 +138,7 @@ impl VideoConverterDumpFozdb { return self; } - match fossilize::StreamArchive::new(&dump_file_path, OpenOptions::new().write(true).read(true).create(create), VIDEOCONV_FOZ_NUM_TAGS) { + match fossilize::StreamArchive::new(&dump_file_path, OpenOptions::new().write(true).read(true).create(create), false /* read-only? */, VIDEOCONV_FOZ_NUM_TAGS) { Ok(newdb) => { self.fozdb = Some(newdb); }, @@ -164,7 +164,7 @@ impl VideoConverterDumpFozdb { } if let Some(fozdb) = &mut self.open(false).fozdb { if let Ok(read_fozdb_path) = std::env::var("MEDIACONV_VIDEO_TRANSCODED_FILE") { - if let Ok(read_fozdb) = fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), VIDEOCONV_FOZ_NUM_TAGS) { + if let Ok(read_fozdb) = fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), true /* read-only? */, VIDEOCONV_FOZ_NUM_TAGS) { let mut chunks = Vec::<(u32, u128)>::new(); for stream_id in fozdb.iter_tag(VIDEOCONV_FOZ_TAG_STREAM).cloned().collect::>() { @@ -306,7 +306,7 @@ impl VideoConvState { loggable_error!(CAT, "MEDIACONV_VIDEO_TRANSCODED_FILE is not set!") })?; - let read_fozdb = match fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), VIDEOCONV_FOZ_NUM_TAGS) { + let read_fozdb = match fossilize::StreamArchive::new(&read_fozdb_path, OpenOptions::new().read(true), true /* read-only? */, VIDEOCONV_FOZ_NUM_TAGS) { Ok(s) => Some(s), Err(_) => None, };