index: fix parallelization

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
pull/579/head
Varun Patil 2023-04-16 12:55:34 -07:00
parent e0eea4c89a
commit d99647291a
4 changed files with 12 additions and 4 deletions

View File

@ -20,6 +20,8 @@ Note: this is a major release and may introduce breaking changes to your workflo
- All media files (excluding folders with `.nomedia` files, default and recommended) - All media files (excluding folders with `.nomedia` files, default and recommended)
- All files in every user's configured timeline folder (not recommended). - All files in every user's configured timeline folder (not recommended).
- All files in a given folder for each user (relative path). - All files in a given folder for each user (relative path).
- **Feature**: You can now run indexing in parallel on multiple threads.
`for i in {1..4}; do (occ memories:index &); done`
- **Feature**: Image editing is now done server-side, and is much faster and more reliable. - **Feature**: Image editing is now done server-side, and is much faster and more reliable.
- PHP Imagick extension is now required for image editing. - PHP Imagick extension is now required for image editing.
- This fixes multiple issues editing images especially in Firefox. - This fixes multiple issues editing images especially in Firefox.

View File

@ -59,12 +59,14 @@ class TimelineWrite
// Check if we need to lock the file // Check if we need to lock the file
if ($lock) { if ($lock) {
$lockKey = 'memories/'.$file->getId(); $lockKey = '/memories/'.$file->getId();
$lockType = ILockingProvider::LOCK_EXCLUSIVE; $lockType = ILockingProvider::LOCK_EXCLUSIVE;
try { // Throw directly to caller if we can't get the lock
$this->lockingProvider->acquireLock($lockKey, $lockType); // This way we don't release someone else's lock
$this->lockingProvider->acquireLock($lockKey, $lockType);
try {
return $this->processFile($file, false, $force); return $this->processFile($file, false, $force);
} finally { } finally {
$this->lockingProvider->releaseLock($lockKey, $lockType); $this->lockingProvider->releaseLock($lockKey, $lockType);

View File

@ -191,7 +191,7 @@ class Index
$this->log("Indexing file {$path}", true); $this->log("Indexing file {$path}", true);
$this->timelineWrite->processFile($file); $this->timelineWrite->processFile($file);
} catch (\OCP\Lock\LockedException $e) { } catch (\OCP\Lock\LockedException $e) {
$this->log("Skipping file {$path} due to lock\n", true); $this->log("Skipping file {$path} due to lock", true);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->error("Failed to index file {$path}: {$e->getMessage()}"); $this->error("Failed to index file {$path}: {$e->getMessage()}");
} finally { } finally {

View File

@ -119,6 +119,10 @@
<br /> <br />
<code>occ memories:index</code> <code>occ memories:index</code>
<br /> <br />
{{ t("memories", "Run index in parallel with 4 threads:") }}
<br />
<code>bash -c 'for i in {1..4}; do (occ memories:index &amp;); done'</code>
<br />
{{ t("memories", "Force re-indexing of all files:") }} {{ t("memories", "Force re-indexing of all files:") }}
<br /> <br />
<code>occ memories:index --force</code> <code>occ memories:index --force</code>