@@ -88,7 +88,9 @@ pub fn untargz(file: File, target: PathBuf) -> Result<(), Box<dyn Error>> {
88
88
let parent_path = target
89
89
. parent ( )
90
90
. ok_or ( format ! ( "Error getting parent of {:?}" , file) ) ?;
91
- archive. unpack ( parent_path) ?;
91
+ if !target. exists ( ) {
92
+ archive. unpack ( parent_path) ?;
93
+ }
92
94
Ok ( ( ) )
93
95
}
94
96
@@ -98,6 +100,9 @@ pub fn unzip(file: File, target: PathBuf) -> Result<(), Box<dyn Error>> {
98
100
99
101
for i in 0 ..archive. len ( ) {
100
102
let mut file = archive. by_index ( i) ?;
103
+ if target. exists ( ) {
104
+ continue ;
105
+ }
101
106
let target_file_name = target. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
102
107
if target_file_name == file. name ( ) {
103
108
log:: debug!(
@@ -108,17 +113,19 @@ pub fn unzip(file: File, target: PathBuf) -> Result<(), Box<dyn Error>> {
108
113
if let Some ( p) = target. parent ( ) {
109
114
create_path_if_not_exists ( p) ;
110
115
}
111
- let mut outfile = File :: create ( & target) ?;
116
+ if !target. exists ( ) {
117
+ let mut outfile = File :: create ( & target) ?;
112
118
113
- // Set permissions in Unix-like systems
114
- #[ cfg( unix) ]
115
- {
116
- use std:: os:: unix:: fs:: PermissionsExt ;
119
+ // Set permissions in Unix-like systems
120
+ #[ cfg( unix) ]
121
+ {
122
+ use std:: os:: unix:: fs:: PermissionsExt ;
117
123
118
- fs:: set_permissions ( & target, fs:: Permissions :: from_mode ( 0o755 ) ) ?;
119
- }
124
+ fs:: set_permissions ( & target, fs:: Permissions :: from_mode ( 0o755 ) ) ?;
125
+ }
120
126
121
- io:: copy ( & mut file, & mut outfile) ?;
127
+ io:: copy ( & mut file, & mut outfile) ?;
128
+ }
122
129
break ;
123
130
}
124
131
}
0 commit comments