Skip to content

Commit 41bc0db

Browse files
authored
Merge pull request #312 from yuchen0cc/main
untar: mv store dirs into extract_file
2 parents 08847cf + 7aa2ffe commit 41bc0db

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/overlaybd/tar/libtar.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ int UnTar::extract_all() {
137137
if (extract_file(filename.c_str()) != 0) {
138138
LOG_ERRNO_RETURN(0, -1, "extract failed, filename `", filename);
139139
}
140-
if (TH_ISDIR(header)) {
141-
dirs.emplace_back(std::make_pair(filename, header.get_mtime()));
142-
}
143140
count++;
144141
}
145142

@@ -230,7 +227,11 @@ int UnTar::extract_file(const char *filename) {
230227
if (i != 0) {
231228
return i;
232229
}
233-
230+
// Directory mtimes must be handled at the end to avoid further
231+
// file creation in them to modify the directory mtime
232+
if (TH_ISDIR(header)) {
233+
dirs.emplace_back(std::make_pair(filename, header.get_mtime()));
234+
}
234235
unpackedPaths.insert(filename);
235236
return 0;
236237
}

0 commit comments

Comments
 (0)