Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan photos of specific directory #1231

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tetebueno
Copy link

@tetebueno tetebueno commented Mar 27, 2024

I've been getting memory exhaustion when scanning all photos collection on an initial load; trying to address #525 I made these changes and was able to scan each year/month directory of photos succesfully like this (the example is for the folder with photos of july '84):

$ docker exec -t -u www-data container-name php occ maps:scan-photos -vvv username Photos/1984/06

I didn't like the ifs all over the implementation, but it's something like a make it work approach. If I can get comments about it, we can make it better.

Cheers.

@tacruc
Copy link
Collaborator

tacruc commented Mar 27, 2024

Thanks for your contribution. Can you pass the path as optional argument?
Do you need help to fix the DCO?

Signed-off-by: tete <tete@Data.lan>
Signed-off-by: tete <tete@Data.lan>
Signed-off-by: tete <tete@Data.lan>
@tetebueno
Copy link
Author

You are very welcome.

Done with DCO, thanks.

Is there anything else besides this so the path parameter is optional? I believe it already is since help command displays it like this: ... [<user_id> [<path>]].

Copy link
Collaborator

@tacruc tacruc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tetebueno,
sorry for the late reply and beeing a little unprecise.
I mean in stead of adding the functions
RescanPhotos->scanUserPhotos
and
PhotofilesService->rescanPath

Just provide an optional parameter to

       private function rescanUserPhotos(string $userId, bool $inBackground=true, sting? $pathToScan===null) {

and PhotofilesService
public function rescan($userId, $inBackground=true, $pathToScan=null) {

and then make an if in the Photofilesservice->rescan

$userFolder = $this->root->getUserFolder($userId)
if ($pathToScan === null) {
          $folder = $userFolder
} else {
          $folder = $userFolder->get($pathToScan);
}
$photos = $this->gatherPhotoFiles($folder, true);

Don't blindly copy my code. It is just typed in here to outline my thought and not tested.

$inBackground = !($input->getOption('now') ?? true);
if ($inBackground) {
echo "Extracting coordinates from photo is performed in a BackgroundJob \n";
}
if ($userId === null) {
$this->userManager->callForSeenUsers(function (IUser $user) use ($inBackground) {
$this->rescanUserPhotos($user->getUID(), $inBackground);
if ($pathToScan === null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($pathToScan === null) {
$this->rescanUserPhotos($user->getUID(), $inBackground, pathToScan);

Comment on lines +101 to +105
if ($pathToScan === null) {
$this->rescanUserPhotos($userId, $inBackground);
} else {
$this->scanUserPhotos($userId, $pathToScan, $inBackground);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($pathToScan === null) {
$this->rescanUserPhotos($userId, $inBackground);
} else {
$this->scanUserPhotos($userId, $pathToScan, $inBackground);
}
$this->rescanUserPhotos($userId, $inBackground, pathToScan);

@tacruc
Copy link
Collaborator

tacruc commented Apr 21, 2024

@tetebueno Do you think you will make the changes befor the NC29 release. Then I would wait with #1244 to include this.

I'm sorry that it is on such short notice after not reviewing for a month. Just have to decide whether to wait or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants