Compare commits
7 Commits
3aa3692384
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 854268d80a | |||
| ed6f5f47bf | |||
| 181424ac70 | |||
| ae869e7a2e | |||
| 173c317238 | |||
| 6a678abc9f | |||
| 5f2f7ea855 |
@@ -32,11 +32,11 @@ jobs:
|
||||
- name: Build Binary
|
||||
run: |
|
||||
go mod tidy
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=${{ steps.get_version.outputs.VERSION }}" -o goencode ./cmd/goencode
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=${{ steps.get_version.outputs.CLEAN_VERSION }}" -o goencode ./cmd/goencode
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
docker build --build-arg APP_VERSION=${{ steps.get_version.outputs.VERSION }} -t cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} .
|
||||
docker build --build-arg APP_VERSION=${{ steps.get_version.outputs.CLEAN_VERSION }} -t cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} .
|
||||
docker push cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }}
|
||||
docker tag cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} cr.jdbnet.co.uk/public/goencode:latest
|
||||
docker push cr.jdbnet.co.uk/public/goencode:latest
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
media/
|
||||
media/
|
||||
goencode
|
||||
+1
-1
@@ -13,7 +13,7 @@ import (
|
||||
var DB *sql.DB
|
||||
|
||||
func Init(cfg *config.DatabaseConfig) error {
|
||||
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?parseTime=true&loc=Local",
|
||||
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?parseTime=true&loc=UTC",
|
||||
cfg.User, cfg.Password, cfg.Host, cfg.Port, cfg.Name)
|
||||
|
||||
var err error
|
||||
|
||||
@@ -138,7 +138,7 @@ func (m *Manager) processWorker() {
|
||||
case <-m.stopChan:
|
||||
return
|
||||
case path := <-m.processChan:
|
||||
m.processFile(path)
|
||||
go m.processFile(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ func (m *Manager) handleEvent(filePath string) {
|
||||
t.Stop()
|
||||
}
|
||||
|
||||
m.timers[filePath] = time.AfterFunc(5*time.Second, func() {
|
||||
m.timers[filePath] = time.AfterFunc(2*time.Minute, func() {
|
||||
m.timersMu.Lock()
|
||||
delete(m.timers, filePath)
|
||||
m.timersMu.Unlock()
|
||||
@@ -176,6 +176,31 @@ func (m *Manager) processFile(filePath string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Wait until the file is fully copied and stable
|
||||
var lastSize int64 = info.Size()
|
||||
var lastModTime time.Time = info.ModTime()
|
||||
var stableCount int
|
||||
|
||||
for {
|
||||
time.Sleep(5 * time.Second)
|
||||
currentInfo, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
return // File was likely deleted during copying
|
||||
}
|
||||
|
||||
if currentInfo.Size() == lastSize && currentInfo.ModTime().Equal(lastModTime) {
|
||||
stableCount++
|
||||
if stableCount >= 3 { // Stable for 15 seconds
|
||||
break
|
||||
}
|
||||
} else {
|
||||
stableCount = 0
|
||||
lastSize = currentInfo.Size()
|
||||
lastModTime = currentInfo.ModTime()
|
||||
}
|
||||
}
|
||||
|
||||
// Re-check after waiting
|
||||
alreadyInQueue, err := db.IsFileAlreadyProcessedOrQueued(filePath)
|
||||
if err != nil {
|
||||
log.Printf("Error checking DB for %s: %v", filePath, err)
|
||||
|
||||
@@ -165,5 +165,6 @@ func (s *Server) handleRequeueJob(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
s.qm.NotifySSE("queue_updated", nil)
|
||||
s.qm.NotifySSE("job_added", nil)
|
||||
s.qm.Trigger()
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user