Skip to content

Commit

Permalink
Add migration to reset scene sizes and scan logic to repopulate if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Infinite committed Dec 15, 2020
1 parent 81e2add commit d8cd40c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

var DB *sqlx.DB
var dbPath string
var appSchemaVersion uint = 15
var appSchemaVersion uint = 16
var databaseSchemaVersion uint

const sqlite3Driver = "sqlite3ex"
Expand Down
1 change: 1 addition & 0 deletions pkg/database/migrations/16_reset_scene_size.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE `scenes` SET `size` = NULL;
6 changes: 3 additions & 3 deletions pkg/manager/task_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func (t *ScanTask) scanScene() *models.Scene {
// if the mod time of the file is different than that of the associated
// scene, then recalculate the checksum and regenerate the thumbnail
modified := t.isFileModified(fileModTime, scene.FileModTime)
if modified {
if modified || !scene.Size.Valid {
scene, err = t.rescanScene(scene, fileModTime)
if err != nil {
logger.Error(err.Error())
Expand Down Expand Up @@ -534,7 +534,7 @@ func (t *ScanTask) scanScene() *models.Scene {
Height: sql.NullInt64{Int64: int64(videoFile.Height), Valid: true},
Framerate: sql.NullFloat64{Float64: videoFile.FrameRate, Valid: true},
Bitrate: sql.NullInt64{Int64: videoFile.Bitrate, Valid: true},
Size: sql.NullString{String: strconv.Itoa(int(videoFile.Size)), Valid: true},
Size: sql.NullString{String: strconv.FormatInt(videoFile.Size, 10), Valid: true},
FileModTime: models.NullSQLiteTimestamp{
Timestamp: fileModTime,
Valid: true,
Expand Down Expand Up @@ -610,7 +610,7 @@ func (t *ScanTask) rescanScene(scene *models.Scene, fileModTime time.Time) (*mod
Height: &sql.NullInt64{Int64: int64(videoFile.Height), Valid: true},
Framerate: &sql.NullFloat64{Float64: videoFile.FrameRate, Valid: true},
Bitrate: &sql.NullInt64{Int64: videoFile.Bitrate, Valid: true},
Size: &sql.NullString{String: strconv.Itoa(int(videoFile.Size)), Valid: true},
Size: &sql.NullString{String: strconv.FormatInt(videoFile.Size, 10), Valid: true},
FileModTime: &models.NullSQLiteTimestamp{
Timestamp: fileModTime,
Valid: true,
Expand Down
3 changes: 3 additions & 0 deletions ui/v2.5/src/components/Changelog/versions/v050.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#### 💥 **Note: After upgrading, all scene file sizes will be 0B until a new [scan](/settings?tab=tasks) is run.

### ✨ New Features
* Allow configuration of visible navbar items.

Expand All @@ -12,4 +14,5 @@
* Support configurable number of threads for scanning and generation.

### 🐛 Bug fixes
* Corrected file sizes on 32bit platforms
* Fixed login redirect to remember the current page.

0 comments on commit d8cd40c

Please sign in to comment.