Skip to content

Commit

Permalink
Actions on directories
Browse files Browse the repository at this point in the history
  • Loading branch information
zer0tonin committed Jun 5, 2023
1 parent db36d01 commit 0bb0f35
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions backend/browser/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ func Move(c *gin.Context) {
func Delete(c *gin.Context) {
path := getAbsolutePath(c.Param("path"))

err := os.Remove(path)
err := os.RemoveAll(path)
if err != nil {
log.Printf("Err: %s", err.Error())
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
"err": "Couldn't move file",
"err": "Couldn't remove file",
})
return
}
Expand Down
15 changes: 12 additions & 3 deletions frontend/src/routes/directory/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Directory = ({ dirPath = "" }) => {
const [fileInfos, setFileInfos] = useState([]);
const [searchQuery, setSearchQuery] = useState("");
const [compare, setCompare] = useState("name_asc");
const [refresh, setRefresh] = useState(0);
const [refresh, setRefresh] = useState(0); // super hacky way to trigger effects

useEffect(() => {
if (dirPath != "" && !window.location.href.endsWith("/")) {
Expand Down Expand Up @@ -128,7 +128,16 @@ const Directory = ({ dirPath = "" }) => {
<Path fileInfo={fileInfo} currentDir={dirPath} />
</td>
<td />
<td />
<td>
<Rename
filePath={filePath}
refresh={() => setRefresh(refresh + 1)}
/>
<Delete
filePath={filePath}
refresh={() => setRefresh(refresh + 1)}
/>
</td>
</tr>
);
}
Expand All @@ -146,7 +155,7 @@ const Directory = ({ dirPath = "" }) => {
<CopyLink filePath={filePath} />
<Rename
filePath={filePath}
refresh={() => setRefresh(refresh + 1)} // very hacky
refresh={() => setRefresh(refresh + 1)}
/>
<Delete
filePath={filePath}
Expand Down
Binary file modified screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0bb0f35

Please sign in to comment.