Merge branch 'master' of github.com:viktorstrate/photoview
This commit is contained in:
commit
e0cfa9038b
|
@ -88,7 +88,7 @@ setInterval(scanner.scanAll, 1000 * 60 * 60 * 4)
|
||||||
// Specify port and path for GraphQL endpoint
|
// Specify port and path for GraphQL endpoint
|
||||||
const graphPath = '/graphql'
|
const graphPath = '/graphql'
|
||||||
|
|
||||||
const endpointUrl = config.host
|
const endpointUrl = new URL(config.host)
|
||||||
// endpointUrl.port = process.env.GRAPHQL_LISTEN_PORT || 4001
|
// endpointUrl.port = process.env.GRAPHQL_LISTEN_PORT || 4001
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -148,7 +148,7 @@ httpServer.listen(
|
||||||
`🚀 GraphQL endpoint ready at ${new URL(server.graphqlPath, endpointUrl)}`
|
`🚀 GraphQL endpoint ready at ${new URL(server.graphqlPath, endpointUrl)}`
|
||||||
)
|
)
|
||||||
|
|
||||||
let subscriptionUrl = endpointUrl
|
let subscriptionUrl = new URL(endpointUrl)
|
||||||
subscriptionUrl.protocol = 'ws'
|
subscriptionUrl.protocol = 'ws'
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
|
|
@ -17,6 +17,16 @@ async function addExifTags({ session, photo }) {
|
||||||
|
|
||||||
const rawTags = await exiftool.read(photo.path)
|
const rawTags = await exiftool.read(photo.path)
|
||||||
|
|
||||||
|
let iso = rawTags.ISO
|
||||||
|
if (typeof iso != 'Number') {
|
||||||
|
try {
|
||||||
|
iso = parseInt(iso)
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Could not parse ISO as int', e, e.stack)
|
||||||
|
iso = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const photoExif = {
|
const photoExif = {
|
||||||
camera: rawTags.Model,
|
camera: rawTags.Model,
|
||||||
maker: rawTags.Make,
|
maker: rawTags.Make,
|
||||||
|
@ -27,7 +37,7 @@ async function addExifTags({ session, photo }) {
|
||||||
fileSize: rawTags.FileSize,
|
fileSize: rawTags.FileSize,
|
||||||
exposure: rawTags.ShutterSpeedValue,
|
exposure: rawTags.ShutterSpeedValue,
|
||||||
aperture: rawTags.ApertureValue,
|
aperture: rawTags.ApertureValue,
|
||||||
iso: rawTags.ISO,
|
iso,
|
||||||
focalLength: rawTags.FocalLength,
|
focalLength: rawTags.FocalLength,
|
||||||
flash: rawTags.Flash,
|
flash: rawTags.Flash,
|
||||||
}
|
}
|
||||||
|
@ -69,6 +79,8 @@ export default async function processImage({ driver, markFinishedImage }, id) {
|
||||||
if (urlResult.records.length == 2) {
|
if (urlResult.records.length == 2) {
|
||||||
markFinishedImage()
|
markFinishedImage()
|
||||||
|
|
||||||
|
session.close()
|
||||||
|
|
||||||
console.log('Skipping image', photo.path)
|
console.log('Skipping image', photo.path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -80,8 +92,12 @@ export default async function processImage({ driver, markFinishedImage }, id) {
|
||||||
{ id }
|
{ id }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
await fs.remove(imagePath)
|
await fs.remove(imagePath)
|
||||||
await fs.mkdirp(imagePath)
|
await fs.mkdirp(imagePath)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Could not remove old image, and make directory', e, e.stack)
|
||||||
|
}
|
||||||
|
|
||||||
let originalPath = photo.path
|
let originalPath = photo.path
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ export default function scanAll({ driver, scanUser }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let session = driver.session()
|
let session = driver.session()
|
||||||
|
|
||||||
let allUserScans = []
|
let usersToScan = []
|
||||||
|
|
||||||
session.run('MATCH (u:User) return u').subscribe({
|
session.run('MATCH (u:User) return u').subscribe({
|
||||||
onNext: record => {
|
onNext: record => {
|
||||||
|
@ -13,21 +13,21 @@ export default function scanAll({ driver, scanUser }) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
allUserScans.push(
|
usersToScan.push(user)
|
||||||
scanUser(user).catch(reason => {
|
},
|
||||||
|
onCompleted: async () => {
|
||||||
|
session.close()
|
||||||
|
|
||||||
|
for (let user of usersToScan) {
|
||||||
|
try {
|
||||||
|
await scanUser(user)
|
||||||
|
} catch (reason) {
|
||||||
console.log(
|
console.log(
|
||||||
`User scan exception for user ${user.username} ${reason}`
|
`User scan exception for user ${user.username} ${reason}`
|
||||||
)
|
)
|
||||||
reject(reason)
|
reject(reason)
|
||||||
})
|
}
|
||||||
)
|
}
|
||||||
},
|
|
||||||
onCompleted: () => {
|
|
||||||
session.close()
|
|
||||||
|
|
||||||
Promise.all(allUserScans).then(() => {
|
|
||||||
resolve()
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
onError: error => {
|
onError: error => {
|
||||||
session.close()
|
session.close()
|
||||||
|
|
|
@ -7,7 +7,6 @@ export default async function scanUser({ driver, scanAlbum }, user) {
|
||||||
console.log('Scanning user', user.username, 'at', user.path)
|
console.log('Scanning user', user.username, 'at', user.path)
|
||||||
|
|
||||||
let foundAlbumIds = []
|
let foundAlbumIds = []
|
||||||
let albumScanPromises = []
|
|
||||||
|
|
||||||
async function scanPath(path, parentAlbum) {
|
async function scanPath(path, parentAlbum) {
|
||||||
console.log('SCAN PATH', path)
|
console.log('SCAN PATH', path)
|
||||||
|
@ -52,7 +51,7 @@ export default async function scanUser({ driver, scanAlbum }, user) {
|
||||||
foundImageOrAlbum = true
|
foundImageOrAlbum = true
|
||||||
nextParentAlbum = album.id
|
nextParentAlbum = album.id
|
||||||
foundAlbumIds.push(album.id)
|
foundAlbumIds.push(album.id)
|
||||||
albumScanPromises.push(scanAlbum(album))
|
await scanAlbum(album)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -108,7 +107,7 @@ export default async function scanUser({ driver, scanAlbum }, user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
foundAlbumIds.push(album.id)
|
foundAlbumIds.push(album.id)
|
||||||
albumScanPromises.push(scanAlbum(album))
|
await scanAlbum(album)
|
||||||
|
|
||||||
session.close()
|
session.close()
|
||||||
}
|
}
|
||||||
|
@ -146,7 +145,11 @@ export default async function scanUser({ driver, scanAlbum }, user) {
|
||||||
)
|
)
|
||||||
|
|
||||||
for (const albumId of deletedAlbumIds) {
|
for (const albumId of deletedAlbumIds) {
|
||||||
|
try {
|
||||||
await fs.remove(getAlbumCachePath(albumId))
|
await fs.remove(getAlbumCachePath(albumId))
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error while trying to delete album from cache', e, e.stack)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -155,7 +158,5 @@ export default async function scanUser({ driver, scanAlbum }, user) {
|
||||||
|
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
await Promise.all(albumScanPromises)
|
|
||||||
|
|
||||||
console.log('User scan complete')
|
console.log('User scan complete')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue