@@ -17,12 +17,14 @@ use log::*;
17
17
18
18
use crate :: backend:: { DecryptWriteBackend , ReadSource , ReadSourceEntry } ;
19
19
use crate :: blob:: BlobType ;
20
+ use crate :: id:: Id ;
20
21
use crate :: index:: { IndexedBackend , Indexer , SharedIndexer } ;
21
22
use crate :: repofile:: { ConfigFile , SnapshotFile } ;
22
23
23
24
pub struct Archiver < BE : DecryptWriteBackend , I : IndexedBackend > {
24
25
file_archiver : FileArchiver < BE , I > ,
25
26
tree_archiver : TreeArchiver < BE , I > ,
27
+ parent_tree : Option < Id > ,
26
28
parent : Parent < I > ,
27
29
indexer : SharedIndexer < BE > ,
28
30
be : BE ,
@@ -34,18 +36,22 @@ impl<BE: DecryptWriteBackend, I: IndexedBackend> Archiver<BE, I> {
34
36
be : BE ,
35
37
index : I ,
36
38
config : & ConfigFile ,
37
- parent : Parent < I > ,
39
+ parent_tree : Option < Id > ,
40
+ ignore_ctime : bool ,
41
+ ignore_inode : bool ,
38
42
mut snap : SnapshotFile ,
39
43
) -> Result < Self > {
40
44
let indexer = Indexer :: new ( be. clone ( ) ) . into_shared ( ) ;
41
45
let mut summary = snap. summary . take ( ) . unwrap ( ) ;
42
46
summary. backup_start = Local :: now ( ) ;
43
47
48
+ let parent = Parent :: new ( & index, parent_tree, ignore_ctime, ignore_inode) ;
44
49
let file_archiver = FileArchiver :: new ( be. clone ( ) , index. clone ( ) , indexer. clone ( ) , config) ?;
45
50
let tree_archiver = TreeArchiver :: new ( be. clone ( ) , index, indexer. clone ( ) , config, summary) ?;
46
51
Ok ( Self {
47
52
file_archiver,
48
53
tree_archiver,
54
+ parent_tree,
49
55
parent,
50
56
be,
51
57
indexer,
@@ -121,14 +127,8 @@ impl<BE: DecryptWriteBackend, I: IndexedBackend> Archiver<BE, I> {
121
127
self . tree_archiver . add ( item) ?;
122
128
}
123
129
124
- let snap = self . finalize_snapshot ( ) ?;
125
- p. finish_with_message ( "done" ) ;
126
- Ok ( snap)
127
- }
128
-
129
- pub fn finalize_snapshot ( mut self ) -> Result < SnapshotFile > {
130
130
let stats = self . file_archiver . finalize ( ) ?;
131
- let ( id, mut summary) = self . tree_archiver . finalize ( ) ?;
131
+ let ( id, mut summary) = self . tree_archiver . finalize ( self . parent_tree ) ?;
132
132
stats. apply ( & mut summary, BlobType :: Data ) ;
133
133
self . snap . tree = id;
134
134
@@ -140,6 +140,7 @@ impl<BE: DecryptWriteBackend, I: IndexedBackend> Archiver<BE, I> {
140
140
let id = self . be . save_file ( & self . snap ) ?;
141
141
self . snap . id = id;
142
142
143
+ p. finish_with_message ( "done" ) ;
143
144
Ok ( self . snap )
144
145
}
145
146
}
0 commit comments