Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
.DS_Store
cbFiles
data
__debug*
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch cbFiles",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/server",
}
]
}
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"path": "web",
"problemMatcher": [],
"label": "npm: dev - html", }
]
}
16 changes: 8 additions & 8 deletions server/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func HandleUpload(w http.ResponseWriter, r *http.Request) {
shareId := r.URL.Query().Get("shareId")

// Check if share exists
sharePath := path.Join("data", "share", shareId)
sharePath := path.Join("data", "share", path.Join("/", shareId))
if _, err := os.Stat(sharePath); os.IsNotExist(err) {
fmt.Println(" The share does not exist, creation is done from Home page. Canceling upload")
return
Expand All @@ -40,7 +40,7 @@ func HandleUpload(w http.ResponseWriter, r *http.Request) {
}
defer fileChunk.Close()

tempFilePath := path.Join(sharePath, fileName)
tempFilePath := path.Join(sharePath, path.Join("/", fileName))
tempFile, err := os.OpenFile(tempFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println(" Error opening or creating temp file :")
Expand Down Expand Up @@ -73,7 +73,7 @@ func HandleSearch(w http.ResponseWriter, r *http.Request) {

// Obtain shareId and Path from URL
shareId := r.URL.Query().Get("shareId")
sharePath := path.Join("data", "share", shareId)
sharePath := path.Join("data", "share", path.Join("/", shareId))

fmt.Println(" Searching for share", shareId)

Expand Down Expand Up @@ -143,11 +143,11 @@ func HandleDelete(w http.ResponseWriter, r *http.Request) {

// Obtain shareId and Path from URL
shareId := r.URL.Query().Get("shareId")
sharePath := path.Join("data", "share", shareId)
sharePath := path.Join("data", "share", path.Join("/", shareId))

// Obtain fileName and filePath from URL
fileName := r.URL.Query().Get("fileName")
filePath := path.Join(sharePath, fileName)
filePath := path.Join(sharePath, path.Join("/", fileName))

fmt.Println(" Deleting file", fileName, "from share", shareId, "...")

Expand All @@ -170,11 +170,11 @@ func HandleDownload(w http.ResponseWriter, r *http.Request) {

// Obtain shareId and Path from URL
shareId := r.URL.Query().Get("shareId")
sharePath := path.Join("data", "share", shareId)
sharePath := path.Join("data", "share", path.Join("/", shareId))

// Obtain fileName and filePath from URL
fileName := r.URL.Query().Get("fileName")
filePath := path.Join(sharePath, fileName)
filePath := path.Join(sharePath, path.Join("/", fileName))

fmt.Println(" Downloading file", fileName, "from share", shareId, "...")

Expand Down Expand Up @@ -264,7 +264,7 @@ func HandleCreate(w http.ResponseWriter, r *http.Request) {

// ...and send it
w.Header().Set("Content-Type", "application/json")
w.Write(responseJSON)
_, _ = w.Write(responseJSON)

fmt.Println("Share created!")
}
2 changes: 1 addition & 1 deletion web/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ func GetUiFs() fs.FS {
}
return embedRoot
// return http.FileServer(http.FS(embedRoot))
}
}
3 changes: 2 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11"
}
},
"proxy": "http://localhost:8080"
}
8 changes: 4 additions & 4 deletions web/src/components/CbFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function CbFiles({ fileInfo, viewMode, loadFiles, searchTerms }) {

if (viewMode === "gallery") {
const newComponents = filteredfileInfo.map((item) => (
<CbFileGallery fileName={item} loadFiles={loadFiles} />
<CbFileGallery key={item} fileName={item} loadFiles={loadFiles} />
));

setComponents(
Expand All @@ -38,7 +38,7 @@ export function CbFiles({ fileInfo, viewMode, loadFiles, searchTerms }) {
);
} else if (viewMode === "list") {
const newComponents = filteredfileInfo.map((item) => (
<CbFileList fileName={item} loadFiles={loadFiles} />
<CbFileList key={item} fileName={item} loadFiles={loadFiles} />
));
setComponents(
<div className="pt-2">
Expand Down Expand Up @@ -238,7 +238,7 @@ function ConfirmSVG() {
width="16"
height="16"
fill="currentColor"
class="bi bi-check2"
className="bi bi-check2"
viewBox="0 0 16 16"
>
<path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0" />
Expand All @@ -253,7 +253,7 @@ function CancelSVG() {
width="16"
height="16"
fill="currentColor"
class="bi bi-x"
className="bi bi-x"
viewBox="0 0 16 16"
>
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708" />
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/CbShareHistoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function EnterSVG() {
width="16"
height="16"
fill="currentColor"
class="bi bi-caret-right"
className="bi bi-caret-right"
viewBox="0 0 16 16"
>
<path d="M6 12.796V3.204L11.481 8zm.659.753 5.48-4.796a1 1 0 0 0 0-1.506L6.66 2.451C6.011 1.885 5 2.345 5 3.204v9.592a1 1 0 0 0 1.659.753" />
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/CbToastsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function CbToastsContainer() {
return (
<ToastContainer className="p-3" position='bottom-end'>
{notifications.map((notification) => (
<Toast onClose={() => { removeNotification(notification.id) }}>
<Toast key={notification.id} onClose={() => { removeNotification(notification.id) }}>
<Toast.Header>
<strong className="me-auto">{notification.header}</strong>
<small>
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/CbUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export function CbUpload({ loadFiles }) {
body: data,
}).then(response => {
if (response.ok) {
addNotification(uploadId, 1, start / file.size * 100, "");
start = end;
end = Math.min(end + chunkSize, file.size);
if (start !== end && !lastChunkSent) {
Expand All @@ -92,6 +91,8 @@ export function CbUpload({ loadFiles }) {
callback();
}
lastChunkSent = true

addNotification(uploadId, 1, start / file.size * 100, "");
} else {
console.log(`Error during upload of file ` + file.name + `. Please check your connection to the sever. err : ${response.status}`);
}
Expand Down