Skip to content

Restrict occ index command to specific folder #184

Closed

Description

@terencedesu

Love the Memories app. Set it up, indexed my instance and set my directory path, but for some reason, if I add new pictures to my photo collection (which is on an external drive) they don't show up in the Memories app. I tried running the index again, but I have since added several more drives and the index command wants to scan everything. I haven't been able to successfully scan the instance again, but also don't want to.
Do I have to index each time, and if so, is there a way to restrict it to just my photo collection?

Activity

  1. pulsejet commented on Nov 11, 2022

    @pulsejet
    Owner

    Ideally you should be adding .nomedia to the folders whose trees you don't want to index.

  2. terencedesu commented on Nov 11, 2022

    @terencedesu
    Author

    Thanks for the quick response. I thought I had done that for the drives I didn't want to index but maybe I missed it. I'll give it a shot.

  3. terencedesu commented on Nov 12, 2022

    @terencedesu
    Author

    Turned out I needed to add the .nomedia to a few more folders. Thanks. Followup question. Do I always have to do the scan command or is there a way to add photos to the nextcloud instance and not have to run the command to have them show up in Memories.

  4. pulsejet commented on Nov 12, 2022

    @pulsejet
    Owner

    In general, you should never need to re run the command except:
    1/ When you upgrade (and the changelog indicates you need to)
    2/ When you change nomedia files and you care about the folders shown (for now, at least)

  5. Glandos commented on Nov 15, 2022

    @Glandos

    Ideally you should be adding .nomedia to the folders whose trees you don't want to index.

    That's one mechanism. But on my Nextcloud storage I have:

    • A lot of documents directory
    • One particular photo/video directory on an external storage, in a subdirectory

    I need to put a .nomedia everywhere else? This would cripple my own computer's directories synchronized with Nextcloud 😞

  6. pulsejet commented on Nov 15, 2022

    @pulsejet
    Owner

    Is there anything you're trying to achieve other than reduce initial indexing time? Indexing everything shouldn't have any impact on performance. As long as you set your timeline path to the directory with your photos, it should be fine.

  7. Glandos commented on Nov 15, 2022

    @Glandos

    You're right, it's not that important.

    Other interesting point: database can be a bit lighter when not containing uninteresting files. On my setup, I have 68k records, and an quick estimate of 10% (6k) are irrelevant.

  8. pulsejet commented on Nov 15, 2022

    @pulsejet
    Owner

    Other interesting point: database can be a bit lighter when not containing uninteresting files. On my setup, I have 68k records, and an quick estimate of 10% (6k) are irrelevant.

    I can't imagine that being more than a few megabytes of storage extra. As I mentioned, this shouldn't have an impact on performance.

  9. vinisxs commented on Nov 30, 2022

    @vinisxs

    The "index all, show some" behavior (#22 (comment)) has a major problem.

    My situation: I have about 400k files and 90% of them are in S3 Glacier Instant Retrieval, which means that they are meant to be sleeping there and it's expensive to access them. The normal pattern is that old files are not accessed often (less than 0.05% each day).

    I could spread .nomedia files across my directories, but I can't control other users directories.

  10. pulsejet commented on Nov 30, 2022

    @pulsejet
    Owner

    @vipseixas what behavior do you suggest then? I'm not sure what makes sense if you don't have control over how users store files / photos.

  11. vinisxs commented on Nov 30, 2022

    @vinisxs

    I think the index command should only act on the directories that are configured as memories root for each user or, as @terencedesu suggested, have a parameter to configure where the index process should start.

    Another idea is a parameter to limit the amount of files to index for a single run, so I can control how many files will be indexed per day and plan the indexing costs through time.

    Later I'll browse through the code to see how the index is done. Is there a technical limitation to a partial index?

  12. pulsejet commented on Nov 30, 2022

    @pulsejet
    Owner

    I think the index command should only act on the directories that are configured as memories root for each user or, as @terencedesu suggested, have a parameter to configure where the index process should start.

    We can't scan the timeline folder selectively because in typical usage the indexing is done before the timeline folder is selected, plus the timeline folder may change. But having a parameter for the directory path to scan is a fair idea.

    I want to note that this still doesn't work if you have absolutely no control over how users store data. At the minimum, you still do need to tell users to place their photos in a certain directory.

    Another idea is a parameter to limit the amount of files to index for a single run, so I can control how many files will be indexed per day and plan the indexing costs through time.

    I'd be wary of this on a production system; users would see half their library of photos and think something went wrong.

    Later I'll browse through the code to see how the index is done. Is there a technical limitation to a partial index?

    No limitation other than what's already mentioned. I'm open to a PR implementing indexing only a fixed path, provided as a system-wide config option (we need this to restrict scanning for future uploads in PostWriteListener).

  13. vinisxs commented on Nov 30, 2022

    @vinisxs

    At the minimum, you still do need to tell users to place their photos in a certain directory.

    That's the idea, I'll announce to the users (basically family and some friends) which path they must use to have their files indexed.

    Another idea is a parameter to limit the amount of files to index for a single run, so I can control how many files will be indexed per day and plan the indexing costs through time.

    I'd be wary of this on a production system; users would see half their library of photos and think something went wrong.

    This could lead to undesirable side effects, for sure...

    I'm open to a PR implementing indexing only a fixed path, provided as a system-wide config option (we need this to restrict scanning for future uploads in PostWriteListener).

    Great, I'll test this as soon it's done. Thanks!

  14. wonx commented on Feb 24, 2023

    @wonx

    I'd also be interested in this. I only have like 4 folders with pictures, but occ memories:index is indexing all the files in the filesystem and it's quite slow. At the moment the process has been running for 11 days, and it's still at the 19.4%, so I can expect the whole indexing process to take around two months.

    I'd rather not fill my directories with .nomedia files. So, the same way occ files:scan has the --path parameter, it would be great if memories would have something similar, so I could just schedule a scan for these 4 dirs with photos.

  15. rhatguy commented on Feb 24, 2023

    @rhatguy

    I have one other use case (although I'm not sure I'd actually use this feature, so take this with a grain of salt). My pictures are organized by years (2023, 2022, 2021...going back 20 years). So I don't really need to be re-indexing anything but the current year most times. If I could limit it, I might update the job at the beginning of every year to only scan the current year. My indexing runs fast enough that that I'm not sure the reduced runtime would matter, and I don't have any other files that aren't part of my picture collection.

  16. pulsejet commented on Feb 24, 2023

    @pulsejet
    Owner

    @rhatguy you shouldn't be needing to re-index at all. Are you uploading files from outside Nextcloud? As long as you use Nextcloud to upload it will automatically trigger hooks to index the new file.

  17. wonx commented on Feb 24, 2023

    @wonx

    @pulsejet One question. I keep my pictures (all my data, actually) in external storage, and once a day I make sure it's sync'd with nextcloud (using occ files:scan, which takes about half an hour), since the files can be modified inside or outside nextcloud.

    So when Nextcloud finds these new pictures with each daily scan, will the hooks be triggered to index the new pictures in memories or I have to run occ memories:index again?

  18. pulsejet commented on Feb 24, 2023

    @pulsejet
    Owner

    @wonx no, scan doesn't trigger hooks, so you'll need to run occ memories:index again in this case.
    But this should be (very) fast: memories doesn't index anything that hasn't changed by checking the modification timestamp. Your subsequent runs should basically skip over all unchanged files.

  19. khlschrnk commented on Mar 5, 2023

    @khlschrnk

    Another idea:
    I restricted the app to a specific user or group via the app admin panel. I would expect that the indexing will not be done for users or groups that are not named here. It still scans for files of all users.
    Alternatively, there could be an option to only scan a specific user: occ memories:index -f [specific_username]

    Maybe that helps and hopefully would be easy to implement.

  20. khlschrnk commented on Mar 5, 2023

    @khlschrnk

    Even more, maybe it makes sense to limit indexing to the folders namen in the settings part of memories? It would not be helpful to have to rerun indexing once someone is changing the folder though. Just another idea.

  21. added this to the 4.13 milestone on Mar 29, 2023
  22. added a commit that references this issue on Apr 13, 2023
    19a3f85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions