Skip to content

Commit

Permalink
fix: rm tmp dir after file download
Browse files Browse the repository at this point in the history
  • Loading branch information
ymarcon committed Jan 25, 2025
1 parent 81b48ff commit d8c8892
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.google.common.collect.Lists;
import jakarta.annotation.Nullable;
import jakarta.ws.rs.core.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.vfs2.*;
import org.apache.shiro.SecurityUtils;
Expand Down Expand Up @@ -605,7 +606,7 @@ private Response getFile(FileObject file, String key) throws IOException {
}
Files.copy(output.toPath(), os);
if (!Strings.isNullOrEmpty(key)) {
output.getParentFile().delete();
FileUtils.deleteQuietly(output.getParentFile());
}
};

Expand Down Expand Up @@ -638,7 +639,7 @@ private Response getFolder(FileObject folder, Collection<String> children, Strin
return true;
}, new File(tmpDir, fileName), key);
Files.copy(output.toPath(), os);
tmpDir.delete();
FileUtils.deleteQuietly(tmpDir);
};

return Response.ok(stream, mimeType)
Expand Down

0 comments on commit d8c8892

Please sign in to comment.