Fix indexer issues & use go generate to create stopwords map

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2019-12-10 16:58:01 +01:00
parent 33603c462a
commit dc46ab9bc8
18 changed files with 10081 additions and 191 deletions

View file

@ -2602,6 +2602,50 @@
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
"integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg="
},
"array.prototype.flat": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.2.tgz",
"integrity": "sha512-VXjh7lAL4KXKF2hY4FnEW9eRW6IhdvFW1sN/JwLbmECbCgACCnBHNyP3lFiYuttr0jxRN9Bsc5+G27dMseSWqQ==",
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.15.0",
"function-bind": "^1.1.1"
},
"dependencies": {
"es-abstract": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.3.tgz",
"integrity": "sha512-WtY7Fx5LiOnSYgF5eg/1T+GONaGmpvpPdCpSnYij+U2gDTL0UPfWrhDw7b2IYb+9NQJsYpCA0wOQvZfsd6YwRw==",
"requires": {
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.1",
"is-callable": "^1.1.4",
"is-regex": "^1.0.4",
"object-inspect": "^1.7.0",
"object-keys": "^1.1.1",
"string.prototype.trimleft": "^2.1.0",
"string.prototype.trimright": "^2.1.0"
}
},
"es-to-primitive": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
"integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==",
"requires": {
"is-callable": "^1.1.4",
"is-date-object": "^1.0.1",
"is-symbol": "^1.0.2"
}
},
"has-symbols": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg=="
}
}
},
"arraybuffer.slice": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz",
@ -3968,9 +4012,9 @@
"integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40="
},
"copy-webpack-plugin": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-5.0.5.tgz",
"integrity": "sha512-7N68eIoQTyudAuxkfPT7HzGoQ+TsmArN/I3HFwG+lVE3FNzqvZKIiaxtYh4o3BIznioxUvx9j26+Rtsc9htQUQ==",
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-5.1.0.tgz",
"integrity": "sha512-0sNrj/Sx7/cWA0k7CVQa0sdA/dzCybqSb0+GbhKuQdOlAvnAwgC2osmbAFOAfha7ZXnreoQmCq5oDjG3gP4VHw==",
"requires": {
"cacache": "^12.0.3",
"find-cache-dir": "^2.1.0",
@ -3982,7 +4026,7 @@
"normalize-path": "^3.0.0",
"p-limit": "^2.2.1",
"schema-utils": "^1.0.0",
"serialize-javascript": "^2.1.0",
"serialize-javascript": "^2.1.2",
"webpack-log": "^2.0.0"
},
"dependencies": {
@ -5122,11 +5166,11 @@
}
},
"eslint-module-utils": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.1.tgz",
"integrity": "sha512-H6DOj+ejw7Tesdgbfs4jeS4YMFrT8uI8xwd1gtQqXssaR0EQ26L+2O/w6wkYFy2MymON0fTwHmXBvvfLNZVZEw==",
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.5.0.tgz",
"integrity": "sha512-kCo8pZaNz2dsAW7nCUjuVoI11EBXXpIzfNxmaoLhXoRDOnqXLC4iSGVRdZPhOitfbdEfMEfKOiENaK6wDPZEGw==",
"requires": {
"debug": "^2.6.8",
"debug": "^2.6.9",
"pkg-dir": "^2.0.0"
},
"dependencies": {
@ -5196,21 +5240,22 @@
}
},
"eslint-plugin-import": {
"version": "2.18.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.2.tgz",
"integrity": "sha512-5ohpsHAiUBRNaBWAF08izwUGlbrJoJJ+W9/TBwsGoR1MnlgfwMIKrFeSjWbt6moabiXW9xNvtFz+97KHRfI4HQ==",
"version": "2.19.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.19.1.tgz",
"integrity": "sha512-x68131aKoCZlCae7rDXKSAQmbT5DQuManyXo2sK6fJJ0aK5CWAkv6A6HJZGgqC8IhjQxYPgo6/IY4Oz8AFsbBw==",
"requires": {
"array-includes": "^3.0.3",
"array.prototype.flat": "^1.2.1",
"contains-path": "^0.1.0",
"debug": "^2.6.9",
"doctrine": "1.5.0",
"eslint-import-resolver-node": "^0.3.2",
"eslint-module-utils": "^2.4.0",
"eslint-module-utils": "^2.4.1",
"has": "^1.0.3",
"minimatch": "^3.0.4",
"object.values": "^1.1.0",
"read-pkg-up": "^2.0.0",
"resolve": "^1.11.0"
"resolve": "^1.12.0"
},
"dependencies": {
"doctrine": {
@ -5221,14 +5266,6 @@
"esutils": "^2.0.2",
"isarray": "^1.0.0"
}
},
"resolve": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz",
"integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
"requires": {
"path-parse": "^1.0.6"
}
}
}
},
@ -8714,6 +8751,11 @@
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.3.1.tgz",
"integrity": "sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA=="
},
"object-inspect": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz",
"integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw=="
},
"object-is": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.0.1.tgz",
@ -11084,9 +11126,9 @@
}
},
"serialize-javascript": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.0.tgz",
"integrity": "sha512-a/mxFfU00QT88umAJQsNWOnUKckhNCqOl028N48e7wFmo2/EHpTo9Wso+iJJCMrQnmFvcjto5RJdAHEvVhcyUQ=="
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz",
"integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ=="
},
"serve-static": {
"version": "1.14.1",
@ -11643,6 +11685,24 @@
}
}
},
"string.prototype.trimleft": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz",
"integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==",
"requires": {
"define-properties": "^1.1.3",
"function-bind": "^1.1.1"
}
},
"string.prototype.trimright": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz",
"integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==",
"requires": {
"define-properties": "^1.1.3",
"function-bind": "^1.1.1"
}
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",

View file

@ -39,7 +39,7 @@
"chrome-finder": "^1.0.6",
"clean-webpack-plugin": "^3.0.0",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^5.0.5",
"copy-webpack-plugin": "^5.1.0",
"core-js": "^3.4.8",
"cross-env": "^5.2.1",
"crypto-random-string": "^3.0.1",
@ -52,7 +52,7 @@
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.2.1",
"eslint-plugin-html": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-node": "^9.2.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",

View file

@ -41,16 +41,16 @@
icon large absolute
class="p-photo-select"
@click.stop.prevent="$clipboard.toggle(photo)">
<v-icon v-if="selection.length && $clipboard.has(photo)" color="white" class="p-photo-select-on">check_circle</v-icon>
<v-icon v-else-if="!$clipboard.has(photo)" color="accent lighten-3" class="p-photo-select-off">radio_button_off</v-icon>
<v-icon v-if="selection.length && $clipboard.has(photo)" color="white" class="t-select t-on">check_circle</v-icon>
<v-icon v-else-if="!$clipboard.has(photo)" color="accent lighten-3" class="t-select t-off">radio_button_off</v-icon>
</v-btn>
<v-btn v-if="hover || photo.PhotoFavorite" :flat="!hover" :ripple="false"
icon large absolute
class="p-photo-like"
@click.stop.prevent="photo.toggleLike()">
<v-icon v-if="photo.PhotoFavorite" color="white" class="p-photo-like-on">favorite</v-icon>
<v-icon v-else color="accent lighten-3" class="p-photo-like-off">favorite_border</v-icon>
<v-icon v-if="photo.PhotoFavorite" color="white" class="t-like t-on">favorite</v-icon>
<v-icon v-else color="accent lighten-3" class="t-like t-off">favorite_border</v-icon>
</v-btn>
</v-img>

View file

@ -36,6 +36,10 @@ class Settings {
return result;
}
changed(key) {
return (this[key] !== this.__originalValues[key]);
}
load() {
return Api.get("settings").then((response) => {
return Promise.resolve(this.setValues(response.data));

View file

@ -9,7 +9,7 @@
height="64"
>
<v-tab id="tab-maintenance" ripple @click="changePath('/library')">
<translate>Maintenance</translate>
<translate>Originals</translate>
</v-tab>
<v-tab-item>
<p-tab-maintenance></p-tab-maintenance>

View file

@ -3,10 +3,10 @@
<v-form ref="form" class="p-photo-import" lazy-validation @submit.prevent="submit" dense>
<v-container fluid>
<p class="subheading">
<span v-if="fileName"><translate>Importing</translate> {{ fileName }}...</span>
<span v-else-if="busy"><translate>Importing files from directory...</translate></span>
<span v-else-if="completed"><translate>Done.</translate></span>
<span v-else><translate>Press button to import photos from directory...</translate></span>
<span v-if="fileName">Importing {{fileName}}...</span>
<span v-else-if="busy">Importing files from directory...</span>
<span v-else-if="completed">Done.</span>
<span v-else>Press button to import photos from directory...</span>
</p>
<v-progress-linear color="secondary-dark" :value="completed" :indeterminate="busy"></v-progress-linear>
@ -58,7 +58,7 @@
const ctx = this;
Notify.blockUI();
Api.post('import', {}, { cancelToken: this.source.token }).then(function () {
Api.post('import', {}, {cancelToken: this.source.token}).then(function () {
Notify.unblockUI();
ctx.busy = false;
ctx.completed = 100;
@ -79,7 +79,7 @@
});
},
handleEvent(ev, data) {
if(this.source) {
if (this.source) {
this.source.cancel('run in background');
this.source = null;
Notify.unblockUI();

View file

@ -3,10 +3,10 @@
<v-form ref="form" class="p-photo-index" lazy-validation @submit.prevent="submit" dense>
<v-container fluid>
<p class="subheading">
<span v-if="fileName"><translate>Indexing</translate> {{ fileName }}...</span>
<span v-else-if="busy"><translate>Indexing photos and sidecar files...</translate></span>
<span v-else-if="completed"><translate>Done.</translate></span>
<span v-else><translate>Press button to start indexing...</translate></span>
<span v-if="fileName">Indexing {{ fileName }}...</span>
<span v-else-if="busy">Indexing photos and sidecar files...</span>
<span v-else-if="completed">Done.</span>
<span v-else>Press button to start indexing...</span>
</p>
<p class="options">
@ -55,7 +55,7 @@
skip: true
},
labels: {
skip: this.$gettext("Skip existing photos and sidecar files"),
skip: this.$gettext("Skip unchanged photos and sidecar files"),
}
}
},

View file

@ -5,13 +5,16 @@
<v-container fluid>
<p class="subheading">
<span v-if="total === 0"><translate>Select photos to start upload...</translate></span>
<span v-else-if="total > 0 && completed < 100"><translate>Uploading</translate> {{current}} <translate>of</translate> {{total}}...</span>
<span v-else-if="indexing"><translate>Upload complete. Indexing...</translate></span>
<span v-else-if="completed === 100"><translate>Done.</translate></span>
<span v-if="total === 0">Select photos to start upload...</span>
<span v-else-if="total > 0 && completed < 100">
Uploading {{current}} of {{total}}...
</span>
<span v-else-if="indexing">Upload complete. Indexing...</span>
<span v-else-if="completed === 100">Done.</span>
</p>
<v-progress-linear color="secondary-dark" v-model="completed" :indeterminate="indexing"></v-progress-linear>
<v-progress-linear color="secondary-dark" v-model="completed"
:indeterminate="indexing"></v-progress-linear>
<v-btn
:disabled="busy"
@ -89,7 +92,7 @@
).then(function () {
ctx.completed = Math.round((ctx.current / ctx.total) * 100);
}).catch(function () {
Notify.error(this.$gettext("Upload failed"));
Notify.error(ctx.$gettext("Upload failed"));
});
}
}
@ -100,12 +103,12 @@
Api.post('import/upload/' + this.started).then(function () {
Notify.unblockUI();
Notify.success(this.$gettext("Upload complete"));
Notify.success(ctx.$gettext("Upload complete"));
ctx.busy = false;
ctx.indexing = false;
}).catch(function () {
Notify.unblockUI();
Notify.error(this.$gettext("Failure while importing uploaded files"));
Notify.error(ctx.$gettext("Failure while importing uploaded files"));
ctx.busy = false;
ctx.indexing = false;
});

View file

@ -60,9 +60,15 @@
this.settings.load();
},
save() {
const reload = this.settings.changed("language");
this.settings.save().then((s) => {
this.$config.updateSettings(s.getValues(), this.$vuetify);
this.$notify.info(this.$gettext("Settings saved"));
if(reload) {
setTimeout(() => window.location.reload(), 100);
}
})
},
},

File diff suppressed because one or more lines are too long

6
go.mod
View file

@ -27,6 +27,7 @@ require (
github.com/jinzhu/gorm v1.9.5
github.com/json-iterator/go v1.1.5 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/leandro-lugaresi/hub v1.1.0
github.com/lucasb-eyer/go-colorful v1.0.2
@ -50,7 +51,7 @@ require (
github.com/satori/go.uuid v1.2.0
github.com/sevlyar/go-daemon v0.1.5
github.com/simplereach/timeutils v1.2.0 // indirect
github.com/sirupsen/logrus v1.2.0
github.com/sirupsen/logrus v1.4.2
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 // indirect
github.com/stretchr/testify v1.4.0
@ -64,11 +65,12 @@ require (
github.com/unrolled/render v0.0.0-20181210145518-4c664cb3ad2f // indirect
github.com/urfave/cli v1.20.0
go.uber.org/atomic v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d // indirect
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 // indirect
golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b // indirect
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect
golang.org/x/text v0.3.1 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect

12
go.sum
View file

@ -161,6 +161,8 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALr
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@ -272,6 +274,8 @@ github.com/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyq
github.com/sirupsen/logrus v0.0.0-20170323161349-3bcb09397d6d/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20150829172844-0d12bf811670/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
@ -329,8 +333,8 @@ golang.org/x/crypto v0.0.0-20180503215945-1f94bef427e3/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d h1:adrbvkTDn9rGnXg2IJDKozEpXXLZN89pdIA+Syt4/u0=
golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 h1:ydJNl0ENAG67pFbB+9tfhiL2pYqLhfoaZFw/cjLhY4A=
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b h1:VHyIDlv3XkfCa5/a81uzaoDkHH4rr81Z62g+xlnO8uM=
@ -355,6 +359,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTm
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -362,6 +367,7 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
@ -382,6 +388,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138 h1:H3uGjxCR/6Ds0Mjgyp7LMK81+LvmbvWWEnJhzk1Pi9E=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c h1:KfpJVdWhuRqNk4XVXzjXf2KAV4TBEP77SYdFGjeGuIE=
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=

View file

@ -88,10 +88,9 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
filePath := mediaFile.RelativePath(i.originalsPath())
fileName := mediaFile.RelativeFilename(i.originalsPath())
fileHash := mediaFile.Hash()
fileChanged := true
fileExists := false
photoExists := false
exists := false
isNew := true
event.Publish("index.file", event.Data{
"fileHash": fileHash,
@ -116,14 +115,12 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
}
} else {
photoQuery = i.db.Unscoped().First(&photo, "id = ?", file.PhotoID)
fileChanged = file.FileHash != fileHash
}
photoExists = photoQuery.Error == nil
exists = fileExists && photoExists
isNew = !exists
if exists && o.SkipExisting() {
if !fileChanged && photoExists && o.SkipUnchanged() {
return indexResultSkipped
}
@ -132,12 +129,12 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
if jpeg, err := mediaFile.Jpeg(); err == nil {
if isNew || o.UpdateLabels {
if fileChanged || o.UpdateLabels {
// Image classification labels
labels = i.classifyImage(jpeg)
}
if isNew || o.UpdateExif {
if fileChanged || o.UpdateExif {
// Read UpdateExif data
if exifData, err := jpeg.Exif(); err == nil {
photo.PhotoLat = exifData.Lat
@ -157,7 +154,7 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
}
}
if isNew || o.UpdateCamera {
if fileChanged || o.UpdateCamera {
// Set UpdateCamera, Lens, Focal Length and F Number
photo.Camera = models.NewCamera(mediaFile.CameraModel(), mediaFile.CameraMake()).FirstOrCreate(i.db)
photo.Lens = models.NewLens(mediaFile.LensModel(), mediaFile.LensMake()).FirstOrCreate(i.db)
@ -168,14 +165,14 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
}
}
if isNew || o.UpdateDate {
if fileChanged || o.UpdateDate {
if photo.TakenAt.IsZero() || photo.TakenAtLocal.IsZero() {
photo.TakenAt = mediaFile.DateCreated()
photo.TakenAtLocal = photo.TakenAt
}
}
if isNew || o.UpdateLocation {
if fileChanged || o.UpdateLocation {
if location, err := mediaFile.Location(); err == nil {
i.db.FirstOrCreate(location, "id = ?", location.ID)
photo.Location = location
@ -206,7 +203,7 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
sort.Sort(labels)
if (isNew || o.UpdateTitle) && photo.PhotoTitleChanged == false {
if (fileChanged || o.UpdateTitle) && photo.PhotoTitleChanged == false {
log.Infof("setting title based on the following labels: %#v", labels)
if len(labels) > 0 && labels[0].Priority >= -1 && labels[0].Uncertainty <= 60 && labels[0].Name != "" { // TODO: User defined title format
log.Infof("label for title: %#v", labels[0])
@ -242,7 +239,7 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
}
}
if (isNew || o.UpdateTitle) && photo.PhotoTitleChanged == false && photo.PhotoTitle == "" {
if (fileChanged || o.UpdateTitle) && photo.PhotoTitleChanged == false && photo.PhotoTitle == "" {
if len(labels) > 0 && labels[0].Priority >= -1 && labels[0].Uncertainty <= 85 && labels[0].Name != "" {
photo.PhotoTitle = fmt.Sprintf("%s / %s", util.Title(labels[0].Name), mediaFile.DateCreated().Format("2006"))
} else if !photo.TakenAtLocal.IsZero() {
@ -287,7 +284,7 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
log.Infof("adding labels: %+v", labels)
if isNew || o.UpdateLabels {
if fileChanged || o.UpdateLabels {
for _, label := range labels {
lm := models.NewLabel(label.Name, label.Priority).FirstOrCreate(i.db)
@ -318,7 +315,7 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
isPrimary = mediaFile.IsJpeg() && (fileName == primaryFile.FileName || fileHash == primaryFile.FileHash)
}
if (isNew || o.UpdateKeywords) && isPrimary {
if (fileChanged || o.UpdateKeywords) && isPrimary {
photo.IndexKeywords(keywords, i.db)
}
@ -332,7 +329,7 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
file.FileMime = mediaFile.MimeType()
file.FileOrientation = mediaFile.Orientation()
if isNew || o.UpdateColors {
if fileChanged || o.UpdateColors {
// Color information
if p, err := mediaFile.Colors(i.thumbnailsPath()); err == nil {
file.FileMainColor = p.MainColor.Name()
@ -342,7 +339,7 @@ func (i *Indexer) indexMediaFile(mediaFile *MediaFile, o IndexerOptions) IndexRe
}
}
if isNew || o.UpdateSize {
if fileChanged || o.UpdateSize {
if mediaFile.Width() > 0 && mediaFile.Height() > 0 {
file.FileWidth = mediaFile.Width()
file.FileHeight = mediaFile.Height()

View file

@ -29,7 +29,7 @@ func (o *IndexerOptions) UpdateAny() bool {
return false
}
func (o *IndexerOptions) SkipExisting() bool {
func (o *IndexerOptions) SkipUnchanged() bool {
return !o.UpdateAny()
}

57
internal/util/gen.go Normal file
View file

@ -0,0 +1,57 @@
// +build ignore
// This generates stopwords.go by running "go generate"
package main
import (
"bufio"
"os"
"io"
"text/template"
)
func main() {
file, err := os.Open("./resources/stopwords.txt")
if err != nil {
panic(err)
}
defer file.Close()
reader := bufio.NewReader(file)
words := []string{}
for {
line, _, err := reader.ReadLine()
if err == io.EOF {
break
}
words = append(words, string(line))
}
f, err := os.Create("stopwords.go")
if err != nil {
panic(err)
}
defer f.Close()
packageTemplate.Execute(f, struct {
Words []string
}{
Words: words,
})
}
var packageTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT.
package util
var Stopwords = map[string]bool{
{{- range .Words }}
{{ printf "%q" . }}: true,
{{- end }}
}`))

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -11,4 +11,6 @@ import (
"github.com/photoprism/photoprism/internal/event"
)
//go:generate go run gen.go
var log = event.Log