{"record":{"id":"fba9a3a1cf94f5fa","repo":"stanfordnlp/CoreNLP","slug":"deleting-more-than-10gb-you-should-do-this-manual","errorCode":null,"errorMessage":"Deleting more than 10GB; you should do this manually","messagePattern":"Deleting more than 10GB; you should do this manually","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/io/IOUtils.java","lineNumber":2039,"sourceCode":"   *\n   * @param file The file or directory to delete.\n   */\n  public static void deleteRecursively(File file) {\n    // Sanity checks\n    if (blockListPathsToRemove.contains(file.getPath())) {\n      throw new IllegalArgumentException(\"You're trying to delete \" + file + \"! I _really_ don't think you want to do that...\");\n    }\n    int count = 0;\n    long size = 0;\n    for (File f : iterFilesRecursive(file)) {\n      count += 1;\n      size += f.length();\n    }\n    if (count > 100) {\n      throw new IllegalArgumentException(\"Deleting more than 100 files; you should do this manually\");\n    }\n    if (size > 10000000000L) {  // 10 GB\n      throw new IllegalArgumentException(\"Deleting more than 10GB; you should do this manually\");\n    }\n    // Do delete\n    if (file.isDirectory()) {\n      File[] children = file.listFiles();\n      if (children != null) {\n        for (File child : children) {\n          deleteRecursively(child);\n        }\n      }\n    }\n    //noinspection ResultOfMethodCallIgnored\n    file.delete();\n  }\n\n  /**\n   * Start a simple console. Read lines from stdin, and pass each line to the callback.\n   * Returns on typing \"exit\" or \"quit\".\n   *","sourceCodeStart":2021,"sourceCodeEnd":2057,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/io/IOUtils.java#L2021-L2057","documentation":"deleteRecursively sums the byte size of every file it would remove and throws this IllegalArgumentException if the total exceeds 10 GB (10000000000L), again to make bulk deletion an explicit manual action.","triggerScenarios":"IOUtils.deleteRecursively on a directory containing more than 10 GB of files, even if the file count is under 100.","commonSituations":"Deleting model checkpoints, video caches, or large datasets with few but huge files; log directories that grew fat with a handful of files.","solutions":["Delete the large directory manually after verifying its contents","Implement your own guarded recursive delete with a limit appropriate to your app","Free space selectively by deleting individual files rather than the whole tree"],"exampleFix":"// before\nIOUtils.deleteRecursively(checkpointDir); // 30 GB\n// after\n// explicitly verified: only .ckpt files inside\nfor (File f : checkpointDir.listFiles((d, n) -> n.endsWith(\".ckpt\"))) { f.delete(); }\ncheckpointDir.delete();","handlingStrategy":"try-catch","validationCode":"long total = 0; try (var s = Files.walk(dir.toPath())) { total = s.filter(Files::isRegularFile).mapToLong(p -> p.toFile().length()).sum(); } if (total > 10_000_000_000L) { /* manual deletion */ }","typeGuard":null,"tryCatchPattern":"try { IOUtils.deleteRecursively(dir); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"more than 10GB\")) { /* manual deletion */ } else throw e; }","preventionTips":["Sum file sizes before large deletes","Prune old files selectively (by age) rather than whole-tree deletes","Monitor cache/checkpoint directory growth"],"tags":["filesystem","delete","safety-guard"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}