Library: Add option to run index and cache cleanup from the UI #3699

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-09-03 16:02:42 +02:00
parent ec1e3f0fb6
commit 0e4ce95ff1
48 changed files with 163 additions and 105 deletions

View file

@ -669,7 +669,7 @@ msgid "Delete"
msgstr "Vee uit"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "حذف"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -669,7 +669,7 @@ msgid "Delete"
msgstr "Выдаліць"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Изтриване на"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Esborrar"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Vymazat"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Slet"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Löschen"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -669,7 +669,7 @@ msgid "Delete"
msgstr "Διαγραφή"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -671,7 +671,7 @@ msgid "Delete"
msgstr ""
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Borrar"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -669,7 +669,7 @@ msgid "Delete"
msgstr "Kustuta"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -669,7 +669,7 @@ msgid "Delete"
msgstr "Ezabatu"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "حذف"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -669,7 +669,7 @@ msgid "Delete"
msgstr "Poista"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Supprimer"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "מחק"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "हटाएं"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Izbriši"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -671,7 +671,7 @@ msgid "Delete"
msgstr "Törlés"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Hapus"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Elimina"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "削除"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "삭제"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "سڕینەوە"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Ištrinti"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Padam"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Slett"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Verwijder"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Usuń"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Apagar"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Excluir"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Ștergeți"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Удалить"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Vymazať"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -669,7 +669,7 @@ msgid "Delete"
msgstr "Izbriši"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Radera"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "ลบ"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Sil"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -788,7 +788,7 @@ msgid "Delete"
msgstr ""
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "Видалити"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "删除"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -672,7 +672,7 @@ msgid "Delete"
msgstr "刪除"
#: src/page/library/index.vue:141
msgid "Delete orphaned index entries, cache files and thumbnails."
msgid "Delete orphaned index entries, sidecar files and thumbnails."
msgstr ""
#: src/component/photo/cards.vue:459 src/dialog/album/edit.vue:148

View file

@ -11,18 +11,18 @@
</p>
<v-autocomplete
v-model="settings.index.path"
color="secondary-dark"
class="my-3 input-index-folder"
hide-details
hide-no-data flat solo browser-autocomplete="off"
:items="dirs"
:loading="loading"
:disabled="busy || !ready"
item-text="name"
item-value="path"
@change="onChange"
@focus="onFocus"
v-model="settings.index.path"
color="secondary-dark"
class="my-3 input-index-folder"
hide-details
hide-no-data flat solo browser-autocomplete="off"
:items="dirs"
:loading="loading"
:disabled="busy || !ready"
item-text="name"
item-value="path"
@change="onChange"
@focus="onFocus"
>
</v-autocomplete>
@ -32,53 +32,65 @@
</p>
<v-layout wrap align-top class="pb-3">
<v-flex xs12 sm6 lg4 class="px-2 pb-2 pt-2">
<v-flex xs12 sm6 lg12 class="px-2 pb-2 pt-2">
<v-checkbox
v-model="settings.index.rescan"
:disabled="busy || !ready"
class="ma-0 pa-0"
color="secondary-dark"
:label="$gettext('Complete Rescan')"
:hint="$gettext('Re-index all originals, including already indexed and unchanged files.')"
prepend-icon="cached"
persistent-hint
@change="onChange"
v-model="settings.index.rescan"
:disabled="busy || !ready"
class="ma-0 pa-0"
color="secondary-dark"
:label="$gettext('Complete Rescan')"
:hint="$gettext('Re-index all originals, including already indexed and unchanged files.')"
prepend-icon="cached"
persistent-hint
@change="onChange"
>
</v-checkbox>
</v-flex>
<v-flex v-if="isAdmin" xs12 sm6 lg12 class="px-2 pb-2 pt-2">
<v-checkbox
v-model="cleanup"
:disabled="busy || !ready"
class="ma-0 pa-0"
color="secondary-dark"
:label="$gettext('Cleanup')"
:hint="$gettext('Delete orphaned index entries, sidecar files and thumbnails.')"
prepend-icon="cleaning_services"
persistent-hint
>
</v-checkbox>
</v-flex>
</v-layout>
<v-btn
:disabled="!busy || !ready"
color="primary-button"
class="white--text ml-0 mt-2 action-cancel"
depressed
@click.stop="cancelIndexing()"
:disabled="!busy || !ready"
color="primary-button"
class="white--text ml-0 mt-2 action-cancel"
depressed
@click.stop="cancelIndexing()"
>
<translate>Cancel</translate>
</v-btn>
<v-btn
:disabled="busy || !ready"
color="primary-button"
class="white--text ml-0 mt-2 action-index"
depressed
@click.stop="startIndexing()"
:disabled="busy || !ready"
color="primary-button"
class="white--text ml-0 mt-2 action-index"
depressed
@click.stop="startIndexing()"
>
<translate>Start</translate>
<v-icon :right="!rtl" :left="rtl" dark>update</v-icon>
</v-btn>
<v-alert
v-if="ready && !busy && config.count.hidden > 1"
:value="true"
color="error"
icon="priority_high"
class="mt-3"
outline
v-if="ready && !busy && config.count.hidden > 1"
:value="true"
color="error"
icon="priority_high"
class="mt-3"
outline
>
<translate
:translate-params="{n: config.count.hidden}">The index currently contains %{n} hidden files.</translate>
<translate :translate-params="{n: config.count.hidden}">The index currently contains %{n} hidden files.</translate>
<translate>Their format may not be supported, they haven't been converted to JPEG yet or there are duplicates.</translate>
</v-alert>
</v-container>
@ -105,6 +117,7 @@ export default {
settings: new Settings(this.$config.settings()),
readonly: this.$config.get("readonly"),
config: this.$config.values,
isAdmin: this.$session.isAdmin(),
started: false,
busy: false,
loading: false,
@ -112,6 +125,7 @@ export default {
subscriptionId: "",
action: "",
fileName: "",
cleanup: false,
source: null,
root: root,
dirs: [root],
@ -189,7 +203,15 @@ export default {
const ctx = this;
Notify.blockUI();
Api.post('index', this.settings.index, {cancelToken: this.source.token}).then(function () {
// Request parameters.
const params = {
path: this.settings.index.path,
rescan: this.settings.index.rescan,
cleanup: this.cleanup,
};
// Submit POST request.
Api.post('index', params, {cancelToken: this.source.token}).then(function () {
Notify.unblockUI();
ctx.busy = false;
ctx.completed = 100;
@ -198,7 +220,7 @@ export default {
Notify.unblockUI();
if (Axios.isCancel(e)) {
// run in background
// Run in background.
return;
}
@ -240,6 +262,8 @@ export default {
this.action = this.$gettext("Updating faces");
} else if (data.step === "previews") {
this.action = this.$gettext("Updating previews");
} else if (data.step === "cleanup") {
this.action = this.$gettext("Cleaning index and cache");
} else {
this.action = this.$gettext("Updating index");
}

View file

@ -65,7 +65,7 @@ func StartIndexing(router *gin.RouterGroup) {
lastRun, lastFound := ind.LastRun()
indexStart := time.Now()
// Start indexing.
// Update file index.
found, indexed := ind.Start(indOpt)
// Only run purge and moments if necessary.
@ -90,17 +90,18 @@ func StartIndexing(router *gin.RouterGroup) {
"step": "purge",
})
// Configure purge options.
prgOpt := photoprism.PurgeOptions{
// Get purge worker instance.
w := get.Purge()
// Purge worker options.
opt := photoprism.PurgeOptions{
Path: filepath.Clean(f.Path),
Ignore: found,
Force: forceUpdate,
}
// Start purging.
prg := get.Purge()
if files, photos, updated, err := prg.Start(prgOpt); err != nil {
// Start purge to remove missing files from search results.
if files, photos, updated, err := w.Start(opt); err != nil {
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": txt.UpperFirst(err.Error())})
return
} else if updated > 0 {
@ -109,6 +110,31 @@ func StartIndexing(router *gin.RouterGroup) {
}
}
// Delete orphaned index entries, sidecar files and thumbnails?
if f.Cleanup && s.User().IsAdmin() {
event.Publish("index.updating", event.Data{
"uid": indOpt.UID,
"action": indOpt.Action,
"step": "cleanup",
})
// Get cleanup worker instance.
w := get.CleanUp()
// Cleanup worker options.
opt := photoprism.CleanUpOptions{
Dry: false,
}
// Start index and cache cleanup.
cleanupStart := time.Now()
if thumbnails, _, sidecars, err := w.Start(opt); err != nil {
log.Errorf("cleanup: %s", err)
} else if total := thumbnails + sidecars; total > 0 {
log.Infof("cleanup: deleted %s in total [%s]", english.Plural(total, "file", "files"), time.Since(cleanupStart))
}
}
// Update moments?
if forceUpdate {
event.Publish("index.updating", event.Data{

View file

@ -71,6 +71,7 @@ func indexAction(ctx *cli.Context) error {
var found fs.Done
var indexed int
// Update file index.
if w := get.Index(); w != nil {
indexStart := time.Now()
convert := conf.Settings().Index.Convert && conf.SidecarWritable()
@ -81,14 +82,17 @@ func indexAction(ctx *cli.Context) error {
log.Infof("index: updated %s [%s]", english.Plural(indexed, "file", "files"), time.Since(indexStart))
}
// Remove missing files from search results.
if w := get.Purge(); w != nil {
purgeStart := time.Now()
// Purge worker options.
opt := photoprism.PurgeOptions{
Path: subPath,
Ignore: found,
Force: ctx.Bool("force") || ctx.Bool("cleanup") || indexed > 0,
}
// Start purge.
purgeStart := time.Now()
if files, photos, updated, err := w.Start(opt); err != nil {
log.Error(err)
} else if updated > 0 {
@ -96,19 +100,22 @@ func indexAction(ctx *cli.Context) error {
}
}
// Delete orphaned index entries, sidecar files and thumbnails?
if ctx.Bool("cleanup") {
cleanupStart := time.Now()
// Get cleanup worker instance.
w := get.CleanUp()
// Cleanup worker options.
opt := photoprism.CleanUpOptions{
Dry: false,
}
// Start cleanup worker.
// Start index and cache cleanup.
cleanupStart := time.Now()
if thumbnails, _, sidecars, err := w.Start(opt); err != nil {
return err
} else if total := thumbnails + sidecars; total > 0 {
log.Infof("cleanup: removed %s in total [%s]", english.Plural(total, "file", "files"), time.Since(cleanupStart))
log.Infof("cleanup: deleted %s in total [%s]", english.Plural(total, "file", "files"), time.Since(cleanupStart))
}
}

View file

@ -1,6 +1,7 @@
package form
type IndexOptions struct {
Path string `json:"path"`
Rescan bool `json:"rescan"`
Path string `json:"path"`
Rescan bool `json:"rescan"`
Cleanup bool `json:"cleanup"`
}

View file

@ -21,7 +21,7 @@ import (
"github.com/photoprism/photoprism/pkg/fs"
)
// CleanUp represents a worker that deletes unneeded data and files.
// CleanUp represents a worker that deletes orphaned index entries, sidecar files and thumbnails.
type CleanUp struct {
conf *config.Config
}
@ -35,7 +35,7 @@ func NewCleanUp(conf *config.Config) *CleanUp {
return instance
}
// Start removes orphan index entries and thumbnails.
// Start index and cache cleanup.
func (w *CleanUp) Start(opt CleanUpOptions) (thumbs int, orphans int, sidecars int, err error) {
defer func() {
if r := recover(); r != nil {
@ -96,7 +96,7 @@ func (w *CleanUp) Start(opt CleanUpOptions) (thumbs int, orphans int, sidecars i
}
}
log.Infof("cleanup: removed %s and %s [%s]", english.Plural(orphans, "index entry", "index entries"), english.Plural(sidecars, "sidecar file", "sidecar files"), time.Since(cleanupStart))
log.Infof("cleanup: removed %s and deleted %s [%s]", english.Plural(orphans, "index entry", "index entries"), english.Plural(sidecars, "sidecar file", "sidecar files"), time.Since(cleanupStart))
// Remove orphan index entries.
if opt.Dry {
@ -159,7 +159,7 @@ func (w *CleanUp) Cache(opt CleanUpOptions) (deleted int, err error) {
log.Info("cleanup: searching for orphaned cache files")
// Find and remove orphan thumbnail files.
// Find and delete orphaned thumbnail files.
for _, dir := range dirs {
err = fastwalk.Walk(dir, func(fileName string, info os.FileMode) error {
base := filepath.Base(fileName)
@ -184,19 +184,19 @@ func (w *CleanUp) Cache(opt CleanUpOptions) (deleted int, err error) {
// Do nothing.
} else if opt.Dry {
deleted++
log.Debugf("cleanup: %s would be removed", logName)
log.Debugf("cleanup: %s would be deleted", logName)
} else if err := os.Remove(fileName); err != nil {
log.Warnf("cleanup: %s in %s", err, logName)
} else {
deleted++
log.Debugf("cleanup: removed %s from cache", logName)
log.Debugf("cleanup: deleted %s from cache", logName)
}
return nil
})
}
log.Infof("cleanup: removed %s from cache [%s]", english.Plural(deleted, "file", "files"), time.Since(cleanupStart))
log.Infof("cleanup: deleted %s from cache [%s]", english.Plural(deleted, "file", "files"), time.Since(cleanupStart))
return deleted, err
}