Announcement

#1 2021-02-16 15:53:15

gabrielwhite
Member
2021-02-16
2

Excluding hidden files from physical albums?

I'm running Piwigo on an Odroid HC4 NAS / Armbian / OMV5.

I'm using physical albums, and (because my desktop computer is a Mac), each directory has the images as well as a bunch of MacOS resource forks, for example:

-rw-rw----  1 gabe users    4096 Feb 15 23:00 ._photo1.JPG
-rw-rw----  1 gabe users    4096 Feb 15 23:00 ._photo2.JPG
-rw-rw----  1 gabe users    4096 Feb 15 23:00 ._photo3.JPG
-rw-rw----  1 gabe users 4475836 May 30  2016 photo1.JPG
-rw-rw----  1 gabe users 4635756 May 30  2016 photo2.JPG
-rw-rw----  1 gabe users 3552726 May 30  2016 photo3.JPG

Piwigo is trying to index the hidden files, but they only contain metadata.

I'm no regex expert, but I put this into the configuration (which seems to work on the online regex simulators):

$conf['sync_chars_regex'] = '/^[^.][a-zA-Z0-9-_. &,]+$/';

But I'm still getting the dotfiles turning up in the galleries.

Any suggestions?

Environment
Piwigo 11.3.0 Check for upgrade
Operating system: Linux
PHP: 7.3.26 (Show info) [2021-02-16 11:41:30]
MySQL: 5.5.5-10.5.8-MariaDB-1:10.5.8+maria~focal [2021-02-16 14:41:30]
Graphics Library: ImageMagick 7.0.10-48

Offline

 

#2 2021-02-16 16:25:42

dummer-esel
Member
2017-01-25
49

Re: Excluding hidden files from physical albums?

I'm no expert on this, but I remember that the . in regex is a kind of wildcard which stands for any character.
So maybe you should try to escape it? (did not try it myself)

$conf['sync_chars_regex'] = '/^[^\.][a-zA-Z0-9-_. &,]+$/';

Offline

 

#3 2021-02-16 18:05:51

erAck
Only trying to help
2015-09-06
1366

Re: Excluding hidden files from physical albums?

Within bracketed set expressions (character classes) characters are literal and must not be escaped (apart from things like \t for tab). However, it's odd that the [^.] exclusion doesn't work (btw, note that your expression now matches only basenames that are at least 2 characters in length but would not match a.jpg), it definitely does as a single PHP statement, i.e.

Code:

<?php
echo preg_match('/^[^.][a-zA-Z0-9-_. &,]+$/','.a') ."\n";
?>

returns 0.

Are you sure you don't have a typo in your config and those resource fork files really start with a U+002E FULL STOP character and you added the modification to your local/config/config.inc.php and not to include/config_default.inc.php before the the other $conf['sync_chars_regex'] = ... statement that would overwrite it and in local/config/config.inc.php it's between the <?php and ?> markers?

Anyway, you could try with a negated lookahead, this expression then also matches a basename of a single character:

Code:

$conf['sync_chars_regex'] = '/^(?!\.)[a-zA-Z0-9-_. &,]+$/';

Running Piwigo at https://erack.net/gallery/

Offline

 

#4 2021-02-16 18:45:04

gabrielwhite
Member
2021-02-16
2

Re: Excluding hidden files from physical albums?

Thanks both for your suggestions.

I'd realised that the local/config/config.inc.php had two references to sync_chars_regex, which I fixed. I also put your suggested updated regex.

The galleries now only include the proper images, and not the dot files.

The sync now generates these errors below. Is this the result of the regex doing its work? Or some other problem?

Thanks!

[./galleries/filesystem/folderthree/._photo1.JPG] PWG-UPDATE-1 (wrong filename)
[./galleries/filesystem/folderthree/._photo2.JPG] PWG-UPDATE-1 (wrong filename)
[./galleries/filesystem/folderthree/._photo3.JPG] PWG-UPDATE-1 (wrong filename)
[./galleries/filesystem/one/._DSCF9436.JPG] PWG-UPDATE-1 (wrong filename)
[./galleries/filesystem/one/._DSCF9439.JPG] PWG-UPDATE-1 (wrong filename)
[./galleries/filesystem/one/._DSCF9441.JPG] PWG-UPDATE-1 (wrong filename)
[./galleries/filesystem/one/._DSCF9442.JPG] PWG-UPDATE-1 (wrong filename)
[./galleries/filesystem/two/._DSCF9446.JPG] PWG-UPDATE-1 (wrong filename)
[./galleries/filesystem/two/._DSCF9447.JPG] PWG-UPDATE-1 (wrong filename)

Offline

 

#5 2021-02-16 20:20:37

erAck
Only trying to help
2015-09-06
1366

Re: Excluding hidden files from physical albums?

Yes, that's in this case a positive acknowledgement that the regex is working..


Running Piwigo at https://erack.net/gallery/

Offline

 

#6 2021-03-06 10:35:17

TOnin
Member
1970-01-01
66

Re: Excluding hidden files from physical albums?

Hi,
Similar question with a reply bringing an idea of code improvment [Github] Piwigo issue #1359
Home » How-To and Troubleshooting » exclude "._" files from scan

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact