|
34 | 34 | #include "switch_file.h" |
35 | 35 | #include "overlaybd/gzip/gz.h" |
36 | 36 | #include "overlaybd/gzindex/gzfile.h" |
| 37 | +#include "overlaybd/tar/tar_file.h" |
37 | 38 |
|
38 | 39 | #define PARALLEL_LOAD_INDEX 32 |
39 | 40 | using namespace photon::fs; |
@@ -71,10 +72,18 @@ IFile *ImageFile::__open_ro_file(const std::string &path) { |
71 | 72 | } |
72 | 73 | file = aligned_file; |
73 | 74 | } |
| 75 | + |
| 76 | + auto tar_file = new_tar_file_adaptor(file); |
| 77 | + if (!tar_file) { |
| 78 | + set_failed("failed to open file as tar file " + path); |
| 79 | + delete file; |
| 80 | + LOG_ERROR_RETURN(0, nullptr, "new_tar_file_adaptor(`) failed", path); |
| 81 | + } |
| 82 | + file = tar_file; |
74 | 83 | // set to local, no need to switch, for zfile and audit |
75 | 84 | ISwitchFile *switch_file = new_switch_file(file, true, path.c_str()); |
76 | 85 | if (!switch_file) { |
77 | | - set_failed("failed to open switch file `" + path); |
| 86 | + set_failed("failed to open switch file " + path); |
78 | 87 | delete file; |
79 | 88 | LOG_ERRNO_RETURN(0, nullptr, "new_switch_file(`) failed", path); |
80 | 89 | } |
@@ -158,10 +167,17 @@ IFile *ImageFile::__open_ro_remote(const std::string &dir, const std::string &di |
158 | 167 | remote_file->ioctl(SET_SIZE, size); |
159 | 168 | remote_file->ioctl(SET_LOCAL_DIR, dir); |
160 | 169 |
|
161 | | - ISwitchFile *switch_file = new_switch_file(remote_file); |
162 | | - if (!switch_file) { |
163 | | - set_failed("failed to open switch file `" + url); |
| 170 | + IFile *tar_file = new_tar_file_adaptor(remote_file); |
| 171 | + if (!tar_file) { |
| 172 | + set_failed("failed to open remote file as tar file " + url); |
164 | 173 | delete remote_file; |
| 174 | + LOG_ERROR_RETURN(0, nullptr, "failed to open remote file as tar file `", url); |
| 175 | + } |
| 176 | + |
| 177 | + ISwitchFile *switch_file = new_switch_file(tar_file, false, url.c_str()); |
| 178 | + if (!switch_file) { |
| 179 | + set_failed("failed to open switch file " + url); |
| 180 | + delete tar_file; |
165 | 181 | LOG_ERROR_RETURN(0, nullptr, "failed to open switch file `", url); |
166 | 182 | } |
167 | 183 |
|
|
0 commit comments