@@ -1116,7 +1116,7 @@ fn split(args: SplitArgs) -> Result<()> {
1116
1116
if config. extract_objects && matches ! ( object_base, ObjectBase :: Vfs ( ..) ) {
1117
1117
// Extract files from the VFS into the object base directory
1118
1118
let target_dir = extract_objects ( & config, & object_base) ?;
1119
- object_base = ObjectBase :: Extracted ( target_dir) ;
1119
+ object_base = ObjectBase :: Directory ( target_dir) ;
1120
1120
}
1121
1121
1122
1122
for module_config in config. modules . iter_mut ( ) {
@@ -2015,25 +2015,36 @@ fn apply_add_relocations(obj: &mut ObjInfo, relocations: &[AddRelocationConfig])
2015
2015
pub enum ObjectBase {
2016
2016
None ,
2017
2017
Directory ( Utf8NativePathBuf ) ,
2018
- Extracted ( Utf8NativePathBuf ) ,
2019
2018
Vfs ( Utf8NativePathBuf , Box < dyn Vfs + Send + Sync > ) ,
2020
2019
}
2021
2020
2022
2021
impl ObjectBase {
2023
2022
pub fn join ( & self , path : & Utf8UnixPath ) -> Utf8NativePathBuf {
2024
2023
match self {
2025
2024
ObjectBase :: None => path. with_encoding ( ) ,
2026
- ObjectBase :: Directory ( base) => base. join ( path. with_encoding ( ) ) ,
2027
- ObjectBase :: Extracted ( base) => extracted_path ( base, path) ,
2025
+ ObjectBase :: Directory ( base) => {
2026
+ // If the extracted file exists, use it directly
2027
+ let extracted = extracted_path ( base, path) ;
2028
+ if fs:: exists ( & extracted) . unwrap_or ( false ) {
2029
+ return extracted;
2030
+ }
2031
+ base. join ( path. with_encoding ( ) )
2032
+ }
2028
2033
ObjectBase :: Vfs ( base, _) => Utf8NativePathBuf :: from ( format ! ( "{}:{}" , base, path) ) ,
2029
2034
}
2030
2035
}
2031
2036
2032
2037
pub fn open ( & self , path : & Utf8UnixPath ) -> Result < Box < dyn VfsFile > > {
2033
2038
match self {
2034
2039
ObjectBase :: None => open_file ( & path. with_encoding ( ) , true ) ,
2035
- ObjectBase :: Directory ( base) => open_file ( & base. join ( path. with_encoding ( ) ) , true ) ,
2036
- ObjectBase :: Extracted ( base) => open_file ( & extracted_path ( base, path) , true ) ,
2040
+ ObjectBase :: Directory ( base) => {
2041
+ // If the extracted file exists, use it directly
2042
+ let extracted = extracted_path ( base, path) ;
2043
+ if fs:: exists ( & extracted) . unwrap_or ( false ) {
2044
+ return open_file ( & extracted, true ) ;
2045
+ }
2046
+ open_file ( & base. join ( path. with_encoding ( ) ) , true )
2047
+ }
2037
2048
ObjectBase :: Vfs ( vfs_path, vfs) => {
2038
2049
open_file_with_fs ( vfs. clone ( ) , & path. with_encoding ( ) , true )
2039
2050
. with_context ( || format ! ( "Using disc image {}" , vfs_path) )
@@ -2045,7 +2056,6 @@ impl ObjectBase {
2045
2056
match self {
2046
2057
ObjectBase :: None => Utf8NativePath :: new ( "" ) ,
2047
2058
ObjectBase :: Directory ( base) => base,
2048
- ObjectBase :: Extracted ( base) => base,
2049
2059
ObjectBase :: Vfs ( base, _) => base,
2050
2060
}
2051
2061
}
0 commit comments