parent
d8f327141f
commit
d3503d5e47
|
@ -112,18 +112,22 @@ class LivePhoto
|
||||||
{
|
{
|
||||||
$fileId = $file->getId();
|
$fileId = $file->getId();
|
||||||
$mtime = $file->getMTime();
|
$mtime = $file->getMTime();
|
||||||
$liveid = $exif['ContentIdentifier'];
|
$liveid = $exif['ContentIdentifier'] ?? null;
|
||||||
if (empty($liveid)) {
|
if (empty($liveid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if entry already exists
|
||||||
$query = $this->connection->getQueryBuilder();
|
$query = $this->connection->getQueryBuilder();
|
||||||
$query->select('fileid')
|
$exists = $query->select('fileid')
|
||||||
->from('memories_livephoto')
|
->from('memories_livephoto')
|
||||||
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
|
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
|
||||||
|
->executeQuery()
|
||||||
|
->fetch()
|
||||||
;
|
;
|
||||||
$prevRow = $query->executeQuery()->fetch();
|
|
||||||
|
|
||||||
|
// Construct query parameters
|
||||||
|
$query = $this->connection->getQueryBuilder();
|
||||||
$params = [
|
$params = [
|
||||||
'liveid' => $query->createNamedParameter($liveid, IQueryBuilder::PARAM_STR),
|
'liveid' => $query->createNamedParameter($liveid, IQueryBuilder::PARAM_STR),
|
||||||
'mtime' => $query->createNamedParameter($mtime, IQueryBuilder::PARAM_INT),
|
'mtime' => $query->createNamedParameter($mtime, IQueryBuilder::PARAM_INT),
|
||||||
|
@ -131,7 +135,8 @@ class LivePhoto
|
||||||
'orphan' => $query->createNamedParameter(false, IQueryBuilder::PARAM_BOOL),
|
'orphan' => $query->createNamedParameter(false, IQueryBuilder::PARAM_BOOL),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($prevRow) {
|
// Insert or update
|
||||||
|
if ($exists) {
|
||||||
$query->update('memories_livephoto')
|
$query->update('memories_livephoto')
|
||||||
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
|
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue