Skip to content

Commit 7d17764

Browse files
committed
fix video deletion issue
1 parent c85aac3 commit 7d17764

5 files changed

Lines changed: 9 additions & 7 deletions

File tree

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
module sentry-picam
22

3-
go 1.13
3+
go 1.17
44

55
require (
66
github.com/gorilla/mux v1.8.0
77
github.com/gorilla/websocket v1.4.2
8-
github.com/ricochet2200/go-disk-usage/du v0.0.0-20210707232629-ac9918953285 // indirect
98
sentry-picam/broker v0.0.0-00010101000000-000000000000
109
sentry-picam/helper v0.0.0-00010101000000-000000000000
1110
sentry-picam/raspivid v0.0.0-00010101000000-000000000000
1211
)
1312

13+
require github.com/ricochet2200/go-disk-usage/du v0.0.0-20210707232629-ac9918953285 // indirect
14+
1415
replace sentry-picam/broker => ./pkg/broker
1516

1617
replace sentry-picam/helper => ./pkg/helper

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
22
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
3-
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
4-
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
53
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
64
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
75
github.com/ricochet2200/go-disk-usage/du v0.0.0-20210707232629-ac9918953285 h1:d54EL9l+XteliUfUCGsEwwuk65dmmxX85VXF+9T6+50=

recordingList.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ func (rec *RecordingList) handleDeleteRecording(w http.ResponseWriter, r *http.R
6262

6363
os.MkdirAll(rec.Folder+"deleteme/", 0777)
6464

65-
os.Rename(rec.Folder+videoID+".mp4", rec.Folder+"deleteme/"+videoID+".mp4")
66-
os.Rename(rec.Folder+videoID+".jpg", rec.Folder+"deleteme/"+videoID+".jpg")
65+
s := strings.Split(videoID, "-")
66+
newFolder := fmt.Sprintf("%s-%s/", s[0], s[1])
67+
os.Rename(rec.Folder+newFolder+videoID+".mp4", rec.Folder+"deleteme/"+videoID+".mp4")
68+
os.Rename(rec.Folder+newFolder+videoID+".jpg", rec.Folder+"deleteme/"+videoID+".jpg")
6769
}
6870

6971
func (rec *RecordingList) handleDestroyRecording(w http.ResponseWriter, r *http.Request) {

sentry-picam

88 Bytes
Binary file not shown.

www/recordings.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
}
4242

4343
function deleteVideo(file) {
44-
fetch('./api/videos/' + file, {method: 'DELETE'})
44+
let videoID = file.split('/')[1];
45+
fetch('./api/videos/' + videoID, {method: 'DELETE'})
4546
.then(function() {
4647
nextVideo();
4748
videoList.splice(videoList.indexOf(file), 1);

0 commit comments

Comments
 (0)