mirror of
https://github.com/ValveSoftware/Proton.git
synced 2024-12-26 14:45:48 +03:00
media-converter: Don't panic on unknown tags for read-only DBs
CW-Bug-Id: #19516
This commit is contained in:
parent
ec7e70b0c0
commit
8f5a92e619
@ -198,7 +198,7 @@ static DUMP_FOZDB: Lazy<Mutex<Option<fossilize::StreamArchive>>> = Lazy::new(||
|
||||
return Mutex::new(None);
|
||||
}
|
||||
|
||||
match fossilize::StreamArchive::new(&dump_file_path, OpenOptions::new().write(true).read(true).create(true), AUDIOCONV_FOZ_NUM_TAGS) {
|
||||
match fossilize::StreamArchive::new(&dump_file_path, OpenOptions::new().write(true).read(true).create(true), false /* read-only? */, AUDIOCONV_FOZ_NUM_TAGS) {
|
||||
Ok(newdb) => Mutex::new(Some(newdb)),
|
||||
Err(_) => Mutex::new(None),
|
||||
}
|
||||
@ -454,7 +454,7 @@ impl AudioConvState {
|
||||
gst_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,
|
||||
};
|
||||
|
@ -197,6 +197,7 @@ impl PayloadEntry {
|
||||
|
||||
pub struct StreamArchive {
|
||||
file: fs::File,
|
||||
read_only: bool,
|
||||
|
||||
seen_blobs: Vec<HashMap<FossilizeHash, PayloadEntry>>,
|
||||
|
||||
@ -210,7 +211,7 @@ pub enum CRCCheck {
|
||||
|
||||
impl StreamArchive {
|
||||
|
||||
pub fn new<P: AsRef<std::path::Path>>(filename: P, fileopts: &OpenOptions, num_tags: usize) -> Result<Self, Error> {
|
||||
pub fn new<P: AsRef<std::path::Path>>(filename: P, fileopts: &OpenOptions, read_only: bool, num_tags: usize) -> Result<Self, Error> {
|
||||
|
||||
let file = fileopts.open(filename)?;
|
||||
|
||||
@ -221,6 +222,7 @@ impl StreamArchive {
|
||||
|
||||
let mut ret = Self {
|
||||
file,
|
||||
read_only,
|
||||
seen_blobs,
|
||||
write_pos: 0,
|
||||
};
|
||||
@ -269,6 +271,10 @@ impl StreamArchive {
|
||||
match res {
|
||||
Ok(p) => {
|
||||
self.write_pos = p;
|
||||
if tag >= self.seen_blobs.len() && self.read_only {
|
||||
/* ignore unknown tags for read-only DBs, otherwise panic */
|
||||
continue;
|
||||
}
|
||||
self.seen_blobs[tag].insert(hash, payload_entry);
|
||||
},
|
||||
|
||||
|
@ -124,7 +124,7 @@ static DUMP_FOZDB: Lazy<Mutex<Option<fossilize::StreamArchive>>> = Lazy::new(||
|
||||
return Mutex::new(None);
|
||||
}
|
||||
|
||||
match fossilize::StreamArchive::new(&dump_file_path, OpenOptions::new().write(true).read(true).create(true), VIDEOCONV_FOZ_NUM_TAGS) {
|
||||
match fossilize::StreamArchive::new(&dump_file_path, OpenOptions::new().write(true).read(true).create(true), false /* read-only? */, VIDEOCONV_FOZ_NUM_TAGS) {
|
||||
Ok(newdb) => Mutex::new(Some(newdb)),
|
||||
Err(_) => Mutex::new(None),
|
||||
}
|
||||
@ -237,7 +237,7 @@ impl VideoConvState {
|
||||
gst_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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user