Skip to content

Commit

Permalink
修改删除缓存文件夹策略
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyong committed Aug 1, 2020
1 parent 9054a22 commit 2f2bd88
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<dependency>
<groupId>io.github.fanyong920</groupId>
<artifactId>jvppeteer</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 4 additions & 0 deletions example/src/main/java/com/ruiyun/example/PageGotoExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ public static void main(String[] args) throws Exception {
argList.add("--no-sandbox");
argList.add("--disable-setuid-sandbox");
Browser browser = Puppeteer.launch(options);
Browser browser2 = Puppeteer.launch(options);
Page page = browser.newPage();
page.goTo("https://www.taobao.com/about/");
browser.close();

Page page1 = browser2.newPage();
page1.goTo("https://www.taobao.com/about/");
}
}
22 changes: 11 additions & 11 deletions src/main/java/com/ruiyun/jvppeteer/core/browser/BrowserRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,17 @@ public void kill() {
removeFolderByCmd(tempDirectory);
// FileUtil.removeFolder(tempDirectory);
//同时把以前没删除干净的文件夹也重新删除一遍
Stream<Path> remainTempDirectories = Files.list(Paths.get(tempDirectory).getParent());
remainTempDirectories.forEach(path -> {
if (path.getFileName().toString().startsWith(Constant.PROFILE_PREFIX)) {
// FileUtil.removeFolder(path.toString());
try {
removeFolderByCmd(path.toString());
} catch (IOException | InterruptedException e) {

}
}
});
// Stream<Path> remainTempDirectories = Files.list(Paths.get(tempDirectory).getParent());
// remainTempDirectories.forEach(path -> {
// if (path.getFileName().toString().startsWith(Constant.PROFILE_PREFIX)) {
//// FileUtil.removeFolder(path.toString());
// try {
// removeFolderByCmd(path.toString());
// } catch (IOException | InterruptedException e) {
//
// }
// }
// });
}

} catch (Exception e) {
Expand Down

0 comments on commit 2f2bd88

Please sign in to comment.