@@ -110,8 +110,7 @@ impl Filesystem for RealFilesystem {
110
110
let link_state = get_file_state ( link) . context ( "get link state" ) ?;
111
111
trace ! ( "Link state: {:#?}" , link_state) ;
112
112
113
- let source = real_path ( source) . context ( "get real path of source" ) ?;
114
- Ok ( compare_symlink ( & source, source_state, link_state) )
113
+ compare_symlink ( source, source_state, link_state)
115
114
}
116
115
117
116
fn compare_template ( & mut self , target : & Path , cache : & Path ) -> Result < TemplateComparison > {
@@ -277,8 +276,7 @@ impl Filesystem for RealFilesystem {
277
276
let source_state = get_file_state ( source) . context ( "get source state" ) ?;
278
277
let link_state = get_file_state ( link) . context ( "get link state" ) ?;
279
278
280
- let source = real_path ( source) . context ( "get real path of source" ) ?;
281
- Ok ( compare_symlink ( & source, source_state, link_state) )
279
+ compare_symlink ( source, source_state, link_state)
282
280
}
283
281
284
282
fn compare_template ( & mut self , target : & Path , cache : & Path ) -> Result < TemplateComparison > {
@@ -293,7 +291,7 @@ impl Filesystem for RealFilesystem {
293
291
}
294
292
295
293
fn remove_file ( & mut self , path : & Path ) -> Result < ( ) > {
296
- let metadata = path. metadata ( ) . context ( "get metadata" ) ?;
294
+ let metadata = path. symlink_metadata ( ) . context ( "get metadata" ) ?;
297
295
let result = if metadata. is_dir ( ) {
298
296
std:: fs:: remove_dir_all ( path)
299
297
} else {
@@ -589,8 +587,7 @@ impl Filesystem for DryRunFilesystem {
589
587
state
590
588
} ;
591
589
592
- let source = real_path ( source) . context ( "get real path of source" ) ?;
593
- Ok ( compare_symlink ( & source, source_state, link_state) )
590
+ compare_symlink ( source, source_state, link_state)
594
591
}
595
592
596
593
fn compare_template ( & mut self , target : & Path , cache : & Path ) -> Result < TemplateComparison > {
@@ -760,11 +757,11 @@ fn compare_symlink(
760
757
source_path : & Path ,
761
758
source_state : FileState ,
762
759
link_state : FileState ,
763
- ) -> SymlinkComparison {
764
- match ( source_state, link_state) {
760
+ ) -> Result < SymlinkComparison > {
761
+ Ok ( match ( source_state, link_state) {
765
762
( FileState :: Missing , FileState :: SymbolicLink ( _) ) => SymlinkComparison :: OnlyTargetExists ,
766
763
( _, FileState :: SymbolicLink ( t) ) => {
767
- if t == source_path {
764
+ if t == real_path ( source_path) . context ( "get real path of source" ) ? {
768
765
SymlinkComparison :: Identical
769
766
} else {
770
767
SymlinkComparison :: Changed
@@ -773,7 +770,7 @@ fn compare_symlink(
773
770
( FileState :: Missing , FileState :: Missing ) => SymlinkComparison :: BothMissing ,
774
771
( _, FileState :: Missing ) => SymlinkComparison :: OnlySourceExists ,
775
772
_ => SymlinkComparison :: TargetNotSymlink ,
776
- }
773
+ } )
777
774
}
778
775
779
776
#[ derive( Debug , PartialEq ) ]
0 commit comments