Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/photos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-10-14 10:52:24 +0300
committerLouis Chemineau <louis@chmn.me>2022-10-19 18:52:23 +0300
commit3da00822d0846b3e56b7aee736b6e7679e3bf3c4 (patch)
tree58b2ee543beb2c19a4b02729dbc30b1c52443af6 /src
parent91d7e881507871f7fdc3ec20d247fdfd47b8020b (diff)
Fix nomedia excludion
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/Photos.vue8
-rw-r--r--src/mixins/FilesByMonthMixin.js6
-rw-r--r--src/services/DavClient.js2
-rw-r--r--src/services/FileInfo.js9
-rw-r--r--src/services/FolderInfo.js9
-rw-r--r--src/services/TaggedImages.js10
-rw-r--r--src/store/files.js13
-rw-r--r--src/views/Folders.vue3
8 files changed, 32 insertions, 28 deletions
diff --git a/src/Photos.vue b/src/Photos.vue
index 7c7e76d2..fe0b8f0d 100644
--- a/src/Photos.vue
+++ b/src/Photos.vue
@@ -164,6 +164,11 @@ export default {
},
async beforeMount() {
+ // Register excluded paths
+ const files = loadState('photos', 'nomedia-paths', [])
+ this.$store.dispatch('setNomediaPaths', files)
+ logger.debug('Known .nomedia and .noimage paths', { files })
+
if ('serviceWorker' in navigator) {
// Use the window load event to keep the page load performant
window.addEventListener('load', () => {
@@ -181,9 +186,6 @@ export default {
} else {
console.debug('Service Worker is not enabled on this browser.')
}
-
- const files = loadState('photos', 'nomedia-paths', [])
- this.$store.dispatch('setNomediaPaths', files)
},
beforeDestroy() {
diff --git a/src/mixins/FilesByMonthMixin.js b/src/mixins/FilesByMonthMixin.js
index 650a79e0..cf2ba251 100644
--- a/src/mixins/FilesByMonthMixin.js
+++ b/src/mixins/FilesByMonthMixin.js
@@ -31,8 +31,10 @@ export default {
const filesByMonth = {}
for (const fileId of this.fetchedFileIds) {
const file = this.files[fileId]
- filesByMonth[file.month] = filesByMonth[file.month] ?? []
- filesByMonth[file.month].push(file.fileid)
+ if (file) {
+ filesByMonth[file.month] = filesByMonth[file.month] ?? []
+ filesByMonth[file.month].push(file.fileid)
+ }
}
// Sort files in sections.
diff --git a/src/services/DavClient.js b/src/services/DavClient.js
index 2d4da082..72c2daf5 100644
--- a/src/services/DavClient.js
+++ b/src/services/DavClient.js
@@ -24,8 +24,10 @@ import { createClient, getPatcher } from 'webdav'
import axios from '@nextcloud/axios'
import parseUrl from 'url-parse'
import { generateRemoteUrl } from '@nextcloud/router'
+import { getCurrentUser } from '@nextcloud/auth'
export const rootPath = 'dav'
+export const prefixPath = `/files/${getCurrentUser().uid}`
// force our axios
const patcher = getPatcher()
diff --git a/src/services/FileInfo.js b/src/services/FileInfo.js
index 2dadf14e..06959038 100644
--- a/src/services/FileInfo.js
+++ b/src/services/FileInfo.js
@@ -20,10 +20,9 @@
*
*/
-import { getCurrentUser } from '@nextcloud/auth'
-import client from './DavClient'
-import request from './DavRequest'
-import { genFileInfo } from '../utils/fileUtils'
+import client, { prefixPath } from './DavClient.js'
+import request from './DavRequest.js'
+import { genFileInfo } from '../utils/fileUtils.js'
/**
* Get a file info
@@ -35,8 +34,6 @@ export default async function(path) {
// getDirectoryContents doesn't accept / for root
const fixedPath = path === '/' ? '' : path
- const prefixPath = `/files/${getCurrentUser().uid}`
-
// fetch listing
const response = await client.stat(prefixPath + fixedPath, {
data: request,
diff --git a/src/services/FolderInfo.js b/src/services/FolderInfo.js
index dd5425ae..9cf94c76 100644
--- a/src/services/FolderInfo.js
+++ b/src/services/FolderInfo.js
@@ -20,10 +20,9 @@
*
*/
-import { getCurrentUser } from '@nextcloud/auth'
-import client from './DavClient'
-import request from './DavRequest'
-import { genFileInfo } from '../utils/fileUtils'
+import client, { prefixPath } from './DavClient.js'
+import request from './DavRequest.js'
+import { genFileInfo } from '../utils/fileUtils.js'
/**
* List files from a folder and filter out unwanted mimes
@@ -35,8 +34,6 @@ export default async function(path) {
// getDirectoryContents doesn't accept / for root
const fixedPath = path === '/' ? '' : path
- const prefixPath = `/files/${getCurrentUser().uid}`
-
// fetch listing
const response = await client.stat(prefixPath + fixedPath, {
data: request,
diff --git a/src/services/TaggedImages.js b/src/services/TaggedImages.js
index 01579314..a0611e4f 100644
--- a/src/services/TaggedImages.js
+++ b/src/services/TaggedImages.js
@@ -20,11 +20,10 @@
*
*/
-import { genFileInfo } from '../utils/fileUtils'
-import { getCurrentUser } from '@nextcloud/auth'
-import { props } from './DavRequest'
-import allowedMimes from './AllowedMimes'
-import client from './DavClient'
+import { genFileInfo } from '../utils/fileUtils.js'
+import { props } from './DavRequest.js'
+import allowedMimes from './AllowedMimes.js'
+import client, { prefixPath } from './DavClient.js'
/**
* Get tagged files based on provided tag id
@@ -53,7 +52,6 @@ export default async function(id, options = {}) {
details: true,
}, options)
- const prefixPath = `/files/${getCurrentUser().uid}`
const response = await client.getDirectoryContents(prefixPath, options)
return response.data
diff --git a/src/store/files.js b/src/store/files.js
index f0681860..6559ce69 100644
--- a/src/store/files.js
+++ b/src/store/files.js
@@ -25,7 +25,7 @@ import moment from '@nextcloud/moment'
import { showError } from '@nextcloud/dialogs'
import logger from '../services/logger.js'
-import client from '../services/DavClient.js'
+import client, { prefixPath } from '../services/DavClient.js'
import Semaphore from '../utils/semaphoreWithPriority.js'
const state = {
@@ -41,10 +41,14 @@ const mutations = {
* @param {Array} newFiles the store mutations
*/
updateFiles(state, newFiles) {
+ const files = {}
newFiles.forEach(file => {
- if (state.nomediaPaths.some(nomediaPath => file.filename.startsWith(nomediaPath))) {
+ // Ignore the file if the path is excluded
+ if (state.nomediaPaths.some(nomediaPath => file.filename.startsWith(nomediaPath)
+ || file.filename.startsWith(prefixPath + nomediaPath))) {
return
}
+
if (file.fileid >= 0) {
file.fileMetadataSizeParsed = JSON.parse(file.fileMetadataSize?.replace(/&quot;/g, '"') ?? '{}')
file.fileMetadataSizeParsed.width = file.fileMetadataSizeParsed?.width ?? 256
@@ -58,11 +62,14 @@ const mutations = {
file.timestamp = moment(file.lastmod).unix() // For sorting
file.month = moment(file.lastmod).format('YYYYMM') // For grouping by month
file.day = moment(file.lastmod).format('MMDD') // For On this day
+
+ // Schedule the file to add
+ files[file.fileid] = file
})
state.files = {
...state.files,
- ...newFiles.reduce((files, file) => ({ ...files, [file.fileid]: file }), {}),
+ ...files,
}
},
diff --git a/src/views/Folders.vue b/src/views/Folders.vue
index 21f9f725..a5f26374 100644
--- a/src/views/Folders.vue
+++ b/src/views/Folders.vue
@@ -64,7 +64,6 @@
<script>
import { mapGetters } from 'vuex'
import { UploadPicker } from '@nextcloud/upload'
-import { getCurrentUser } from '@nextcloud/auth'
import { NcEmptyContent } from '@nextcloud/vue'
import VirtualGrid from 'vue-virtual-grid'
@@ -72,6 +71,7 @@ import FileLegacy from '../components/FileLegacy.vue'
import Folder from '../components/Folder.vue'
import HeaderNavigation from '../components/HeaderNavigation.vue'
+import { prefixPath } from '../services/DavClient.js'
import allowedMimes from '../services/AllowedMimes.js'
import getAlbumContent from '../services/AlbumContent.js'
@@ -266,7 +266,6 @@ export default {
* @param {Upload[]} uploads the newly uploaded files
*/
onUpload(uploads) {
- const prefixPath = `/files/${getCurrentUser().uid}`
uploads.forEach(async upload => {
const relPath = upload.path.split(prefixPath).pop()
const file = await getFileInfo(relPath)