MCPcopy Create free account
hub / github.com/e2wugui/zeze / distribute

Method distribute

ZezeJava/ZezeJava/src/main/java/Zeze/Hot/HotAgent.java:159–187  ·  view source on GitHub ↗
(File distributeDir)

Source from the content-addressed store, hash-verified

157 }
158
159 public void distribute(File distributeDir) throws Exception {
160 var files = distributeDir.listFiles();
161 if (null == files)
162 return;
163
164 for (var file : files) {
165 if (file.isDirectory()) {
166 //distributeFiles(distributeDir);
167 continue;
168 }
169 //if (!file.getName().endsWith(".jar"))
170 // continue;
171 var fileRelativeName = distributeDir.toPath().relativize(file.toPath()).toString().replace("\\", "/");
172 var md5 = MessageDigest.getInstance("MD5");
173 var fileOffset = openFile(fileRelativeName);
174 try (var bis = new BufferedInputStream(new FileInputStream(file))) {
175 md5To(md5, bis, fileOffset);
176 var buffer = new byte[16 * 1024];
177 var rc = 0;
178 while ((rc = bis.read(buffer)) >= 0) {
179 md5.update(buffer, 0, rc);
180 appendFile(fileRelativeName, fileOffset, buffer, 0, rc);
181 fileOffset += rc;
182 }
183 } finally {
184 closeFile(fileRelativeName, new Binary(md5.digest()));
185 }
186 }
187 }
188
189 private static void md5To(MessageDigest md5, BufferedInputStream bis, long toOffset) throws IOException {
190 var buffer = new byte[16 * 1024];

Callers 1

packMethod · 0.80

Calls 10

openFileMethod · 0.95
md5ToMethod · 0.95
appendFileMethod · 0.95
closeFileMethod · 0.95
digestMethod · 0.80
replaceMethod · 0.65
updateMethod · 0.65
toStringMethod · 0.45
getInstanceMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected