Skip to content

Commit

Permalink
Merge pull request #1362 from nextcloud/v1.6.0
Browse files Browse the repository at this point in the history
v1.6.0
  • Loading branch information
tacruc authored Dec 31, 2024
2 parents a35398d + b590c04 commit 586784d
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 91 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.6.0 - 2024.12.31 Scan photos of specific directory
- Scan photos of specific directory [#1231](https://github.com/nextcloud/maps/pull/1231) @tetebueno


## 1.5.0 - 2024.11.16 Nextcloud Hub 9
- Update OSM tile service URL [#1295](https://github.com/nextcloud/maps/pull/1295) @StyXman
- Support Nextcloud 30, update CSP header [1336](https://github.com/nextcloud/maps/pull/1336) @Ma27
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- **📱 Devices:** Lost your phone? Check the map!
- **〰 Tracks:** Load GPS tracks or past trips. Recording with [PhoneTrack](https://f-droid.org/en/packages/net.eneiluj.nextcloud.phonetrack/) or [OwnTracks](https://owntracks.org) is planned.
]]></description>
<version>1.5.0</version>
<version>1.6.0</version>
<licence>agpl</licence>
<author mail="eneiluj@posteo.net">Julien Veyssier</author>
<author mail="kontakt+github@arne.email">Arne Hamann</author>
Expand Down
172 changes: 86 additions & 86 deletions lib/Command/RescanPhotos.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,94 +26,94 @@

class RescanPhotos extends Command {

protected IUserManager $userManager;
protected OutputInterface $output;
protected IManager $encryptionManager;
protected PhotofilesService $photofilesService;
protected IConfig $config;
protected IUserManager $userManager;
protected OutputInterface $output;
protected IManager $encryptionManager;
protected PhotofilesService $photofilesService;
protected IConfig $config;

public function __construct(
IUserManager $userManager,
IManager $encryptionManager,
PhotofilesService $photofilesService,
IConfig $config) {
parent::__construct();
$this->userManager = $userManager;
$this->encryptionManager = $encryptionManager;
$this->photofilesService = $photofilesService;
$this->config = $config;
}
public function __construct(
IUserManager $userManager,
IManager $encryptionManager,
PhotofilesService $photofilesService,
IConfig $config) {
parent::__construct();
$this->userManager = $userManager;
$this->encryptionManager = $encryptionManager;
$this->photofilesService = $photofilesService;
$this->config = $config;
}

/**
* @return void
*/
protected function configure() {
$this->setName('maps:scan-photos')
->setDescription('Rescan photos GPS exif data')
->addArgument(
'user_id',
InputArgument::OPTIONAL,
'Rescan photos GPS exif data for the given user'
)
->addArgument(
'path',
InputArgument::OPTIONAL,
'Scan photos GPS exif data for the given path under user\'s files without wiping the database.'
)
->addOption(
'now',
null,
InputOption::VALUE_NONE,
'Dot the rescan now and not as background jobs. Doing it now might run out of memory.'
);
}
/**
* @return void
*/
protected function configure() {
$this->setName('maps:scan-photos')
->setDescription('Rescan photos GPS exif data')
->addArgument(
'user_id',
InputArgument::OPTIONAL,
'Rescan photos GPS exif data for the given user'
)
->addArgument(
'path',
InputArgument::OPTIONAL,
'Scan photos GPS exif data for the given path under user\'s files without wiping the database.'
)
->addOption(
'now',
null,
InputOption::VALUE_NONE,
'Dot the rescan now and not as background jobs. Doing it now might run out of memory.'
);
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
if ($this->encryptionManager->isEnabled()) {
$output->writeln('Encryption is enabled. Aborted.');
return 1;
}
$this->output = $output;
$userId = $input->getArgument('user_id');
$pathToScan = $input->getArgument('path');
$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, string $pathToScan) use ($inBackground) {
$this->rescanUserPhotos($user->getUID(), $inBackground, $pathToScan);
});
} else {
$user = $this->userManager->get($userId);
if ($user !== null) {
$this->rescanUserPhotos($userId, $inBackground, $pathToScan);
}
}
return 0;
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
if ($this->encryptionManager->isEnabled()) {
$output->writeln('Encryption is enabled. Aborted.');
return 1;
}
$this->output = $output;
$userId = $input->getArgument('user_id');
$pathToScan = $input->getArgument('path');
$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, string $pathToScan) use ($inBackground) {
$this->rescanUserPhotos($user->getUID(), $inBackground, $pathToScan);
});
} else {
$user = $this->userManager->get($userId);
if ($user !== null) {
$this->rescanUserPhotos($userId, $inBackground, $pathToScan);
}
}
return 0;
}

/**
* @param string $userId
* @param bool $inBackground
* @param string $pathToScan
* @return void
* @throws \OCP\PreConditionNotMetException
*/
private function rescanUserPhotos(string $userId, bool $inBackground = true, string $pathToScan = null) {
echo '======== User ' . $userId . ' ========' . "\n";
$c = 1;
foreach ($this->photofilesService->rescan($userId, $inBackground, $pathToScan) as $path) {
echo '[' . $c . '] Photo "' . $path . '" added' . "\n";
$c++;
}
if ($pathToScan === null) {
$this->config->setUserValue($userId, 'maps', 'installScanDone', 'yes');
}
}
/**
* @param string $userId
* @param bool $inBackground
* @param string $pathToScan
* @return void
* @throws \OCP\PreConditionNotMetException
*/
private function rescanUserPhotos(string $userId, bool $inBackground = true, ?string $pathToScan = null) {
echo '======== User ' . $userId . ' ========' . "\n";
$c = 1;
foreach ($this->photofilesService->rescan($userId, $inBackground, $pathToScan) as $path) {
echo '[' . $c . '] Photo "' . $path . '" added' . "\n";
$c++;
}
if ($pathToScan === null) {
$this->config->setUserValue($userId, 'maps', 'installScanDone', 'yes');
}
}
}
2 changes: 1 addition & 1 deletion lib/Service/PhotofilesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private function gatherPhotoFiles($folder, $recursive) {
}
try {
$notes = array_merge($notes, $this->gatherPhotoFiles($node, $recursive));
} catch (\OCP\Files\StorageNotAvailableException | \Exception $e) {
} catch (\OCP\Files\StorageNotAvailableException|\Exception $e) {
$msg = 'WARNING: Could not access ' . $node->getName();
echo($msg . "\n");
$this->logger->error($msg);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maps",
"version": "1.5.0",
"version": "1.6.0",
"description": "Maps app",
"main": "main.js",
"directories": {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ export default {
action.callback({
id: 'geo:' + e.latlng.lat + ',' + e.latlng.lng,
name: t('maps', 'Shared location'),
latitude: e.latlng.lat,
longitude: e.latlng.lng,
latitude: e.latlng.lat.toString(),
longitude: e.latlng.lng.toString(),
})
},
})
Expand Down

0 comments on commit 586784d

Please sign in to comment.