Module: Folder Sync
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
Folder Sync is a module that allows you to create an exact replica of your local folder/images structure in the Gallery. http://codex.galleryproject.org/Gallery3:Modules:folder_sync It consists of two parts: This module was initially born as an enhanced version of stadard ServerAdd module. But then it eventually evolved into its separate module. You can see initial discussion here: http://gallery.menalto.com/node/105847 |
|
utku89
Joined: 2012-10-12
Posts: 8 |
![]() |
Hey, Also it would be great if you can add a feature letting user specify an album for synchronized images. |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
I will update the file to fix the E_STRICT warning. |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
As for the feature request, you CAN change where your images will be synchronized to: in folder_sync/controllers/folder_sync.php line 119: Quote:
$entry->item_id = 1; Change 1 to the album_id of desired container album (album_id #1 is the root album) |
|
deanshavit
Joined: 2012-09-28
Posts: 23 |
![]() |
I've got everything working correctly - as far as importing goes. However, delete doesn't work - is the feature fully implemented? |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
By default cronjob doesn't perform deletions unless you explicitly allowed it in the options menu: Admin Dashboard -> Settings -> Folder Sync -> Process deleted item? Also, deletions performed once all images have been imported. |
|
deanshavit
Joined: 2012-09-28
Posts: 23 |
![]() |
Thanks for the response. I do have the option checked, but no deletions happen. Here's the output from when I run the command manually: ORM_Validation_Exception [ 44 ]: ORM Validation has failed for items model |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
I wish Gallery exception messages were more descriptive. There are multiple reasons when Gallery throws "ORM Validation has failed for items model" exception. Would you be willing in doing some debugging? |
|
deanshavit
Joined: 2012-09-28
Posts: 23 |
![]() |
Would be more than happy to help - what do I need to do? |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
What version of Gallery are you running? Looking at the output, I see path "/mysite.com/modules/videos/" which is not present in my version. Is that a separate module you installed? |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
Never mind: in my installation that file is in different location. Here is the relevant code: Quote:
if ($this->id == 1) { Basically, it looks like my module is trying to delete the root folder, because the path you entered in the settings is not found. I just committed a fix: update the module and try again. https://github.com/siburny/gallery3/commit/095292a7afdba80c010240677eb3c73036a7a3ea |
|
deanshavit
Joined: 2012-09-28
Posts: 23 |
![]() |
I've applied that one-line diff but still get the same error: ORM_Validation_Exception [ 44 ]: ORM Validation has failed for items model |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
Oh stupid me: it should be " && $entry->item_id > 1" like that: https://github.com/siburny/gallery3/commit/28964f7da3cec7dd8ed3982abd085d68cdb99b3f |
|
deanshavit
Joined: 2012-09-28
Posts: 23 |
![]() |
Working perfectly now! Thanks so much! |
|
ecar
Joined: 2012-12-19
Posts: 5 |
![]() |
I'm trying it for the first time and kept getting segmentation fault with cron.php. I figure it may be a php.ini issue running a cron job so I use php -c and specified the php.ini that comes with gallery. I was getting error messages and found I needed to set a timezone in php.ini. Now I just get a general "Dang... Something went wrong!" message I do get several warnings: Quote:
Notice: Undefined index: SCRIPT_NAME in /home/enricong/public_html/gallery/application/config/config.php on line 45 Is there a way to get more details on whats going wrong? Also when I try "Folder Sync" from the add menu, it just hangs If I run it from the shell it seems to work ok. Quote:
ORM_Validation_Exception [ 44 ]: ORM Validation has failed for items model |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
First set of warning has something to do with your particular PHP installation: it doesn't supply $_SERVER in the command line mode. thank you for pointing out Add menu: it's actually a "leftover" that is not supposed to be there. As for the exception, it's hard to tell what field or validation rule triggers it. I will add additional Exception handling, so we can see what's going on. |
|
ecar
Joined: 2012-12-19
Posts: 5 |
![]() |
$_SERVER is not being populated I get: failing on session_start() from Session.php(190) I think the problem is that I am only permitted to run the cron job under my own name. |
|
dman89
Joined: 2012-12-31
Posts: 1 |
![]() |
siburny wrote:
As for the feature request, you CAN change where your images will be synchronized to: Hi siburny, Thanks for the module - it works great! I'm having one bit of trouble with it, however. I'm trying to change my sync folder to a different album (id 1385), but it won't seem to change - it always will only sync to the root album. I've changed folder_sync.php as suggested - Line 119 now reads Quote:
$entry->item_id = 1385; However, when I call cron.php, it still will only sync to the root directory. Do you have any suggestions as to where to go next? Thanks again and happy holidays! |
|
Hdi
Joined: 2013-01-04
Posts: 3 |
![]() |
Thank you for great module! photos(root folder) 2003 2004(years) 01 02 03 04 05 06... (month for each year) 01 02 03... (day of month for each month) But when I trying to generate album from root folder, I only get empty albums for years and monthes. |
|
Hdi
Joined: 2013-01-04
Posts: 3 |
![]() |
Here my error log. Thanks! 2013-01-05 11:10:02 +00:00 --- error: ORM_Validation_Exception [ 44 ]: ORM Validation has failed for items model 2013-01-05 11:10:02 +00:00 --- error: Kohana_PHP_Exception [ 8192 ]: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 |
|
Hdi
Joined: 2013-01-04
Posts: 3 |
![]() |
Never mind. 255 master-branch code solved my problem. Thank you for the excellent module! |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
I will do a quick test to see what might be happening here ... [update] |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
@Hdi Glad it worked for you! |
|
spags
Joined: 2010-03-26
Posts: 120 |
![]() |
I've been working on a really rough module to automatically move photos into a calendar-style structure. I was just going to use Server Add but Folder Sync could be an ideal interface into this. My Calendar auto-structure module is slow because it involves a lot of file moves however Folder Sync could trigger it all at sometime like midnight. I see the possibility where Folder Sync automatically picks up images from an import location and then passes them onto the sync destination where the Calendar auto-structure module will perform the slow structuring process. What are the chances of removing that hard-coded destination sync location (folder_sync/controllers/folder_sync.php line 119) to at least putting it to a user-specified location? While it should be done at the module installation stage, a quick change at line 119 to something like the following would be enough: if (module::get_var("folder_sync","destination_folder_id")=="") { module::set_var("folder_sync", "destination_folder_id", 1); } $entry->item_id = module::get_var("folder_sync","destination_folder_id"); This way, the user can go into the Advanced options to change the destination without modifying any code. Of course, they still need to know the id of the destination, but its a start. |
|
arturmaj
Joined: 2008-02-25
Posts: 2 |
![]() |
Thank you siburny for the plugin. |
|
arturmaj
Joined: 2008-02-25
Posts: 2 |
![]() |
I did help myself. It works great. |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
@spags Will update the code with your suggestions. |
|
cnidus
Joined: 2013-01-22
Posts: 3 |
![]() |
Having problems getting this up and running. I have read through the thread and now I am stuck. I am using build # 269. I have the module installed and configured in Gallery3. When I run the cron command from the prompt, I get the following error: $ /usr/bin/php /var/www/gallery3/modules/folder_sync/cron.php This is the same error as ecar and Hdi above, but Hdi's solution (using build 255) does not help me. ecar mentioned that it could be a rights issue of some sort, so I dropped the php command into a crontab for 'www-data', but no joy. Also, I tried to specify in the shell that the php command be run by www-data: as root: su www-data -c /usr/bin/php /var/www/gallery3/modules/folder_sync/cron.php Again, no joy, it actually just hangs. So...any ideas? What am I missing? Thanks. |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
@cnidus Can you please check in the log file (gallery/var/logs) and see what validation it failed and what item? Alternatively, you can try to run a cronjob in the browser (http://DOMAIN/index.php/folder_sync/cron) and see which item triggers the exception. |
|
cnidus
Joined: 2013-01-22
Posts: 3 |
![]() |
Thanks for the quick reply. My log shows that same error as Hdi; 2013-01-22 13:09:12 -06:00 --- error: Validation errors: Array Running the cronjob in the browser (http://DOMAIN/index.php/folder_sync/cron) gives that same list of errors as in my previous message. Nothing seems different. The first little snip of code from the ORM_Validation_Exception.php is as follows: SYSPATH/libraries/ORM_Validation_Exception.php[ 20 ] Is this helpful? |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
It's a step in the right direction: there is a item in your Gallery that doesn't have a valid name (or extension), hense the "illegal_data_file_extension" exception. When you run through a browser, you can actually see parameters in the stacktrace; just click on it. We need to find which item_id triggers the exception, and then look at it to figure out what's wrong. Can you send me a link to your domain in private message? |
|
cnidus
Joined: 2013-01-22
Posts: 3 |
![]() |
I think I figured it out. Your mention of something not having a valid name clued me in. There is a quirk in how linux handles spaces in folder names and that was gunking up the works (either with the module or gallery3). Changed the folder name to a non-space using name and http://DOMAIN/index.php/folder_sync/cron no longer piches a fit. Will try the cron job tonight. Thanks. |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
Yeah! I really need to add some exception trapping and handling to make our lives easier |
|
mikeage
![]()
Joined: 2005-01-23
Posts: 138 |
![]() |
I was looking at the code to folder_sync and server_add while I considered writing a similar module (my idea is to automatically sort images by EXIF creation time, rather than by filesystem path), and I noticed that since you branched off from server_add, there have been some changes made there (mostly small things, like the addition of html::clean or ajax::response instead of just a print()) that might interest you. This is just an FYI; none of them look horribly critical, but they're probably more "right". |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
Thanks, I will take a look at what has been changed! I know for sure video handling was changed completely, so I need to port it over to my module too. |
|
mmeinesz
Joined: 2013-01-28
Posts: 1 |
![]() |
I just wanted to say thank you for the folder_sync module. |
|
suprsidr
![]()
Joined: 2005-04-17
Posts: 8339 |
![]() |
Gallery3 does not yet have an external embed API for full embedding in applications like WP You can display your gallery3 items in WP but there is no user mapping nor any admin functionality. -s |
|
sae@nycradio.com
Joined: 2013-01-14
Posts: 7 |
![]() |
I'm feeling very stupid. I can't figure out how to down load the module. Running it will be another issue. |
|
sae@nycradio.com
Joined: 2013-01-14
Posts: 7 |
![]() |
I get this error when I try to run cron.php. Do I have to run it as a cron job or can it be reun from the command line like shown below? The module is installed and I can configure it via galler3. www@theanswer:~/gallery3/modules/folder_sync$ ./cron.php |
|
mikeage
![]()
Joined: 2005-01-23
Posts: 138 |
![]() |
Try running "php cron.php" instead of "./cron.php" |
|
sae@nycradio.com
Joined: 2013-01-14
Posts: 7 |
![]() |
That was it. Thank You very much. |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
Make sure you run as apache user to prevent permissions problem. |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
sae@nycradio.com wrote:
I'm feeling very stupid. I can't figure out how to down load the module. Running it will be another issue. GIT is a version control system, that manages the code. If you don't want to mess with GIT, you can download a zip file of the module here: https://github.com/siburny/gallery3/blob/master/modules/folder_sync.zip |
|
sae@nycradio.com
Joined: 2013-01-14
Posts: 7 |
![]() |
Thanks |
|
wink_wink
Joined: 2012-10-24
Posts: 10 |
![]() |
Folder sync has transformed the way I can use Gallery3. Thank you! However, I'm still tweaking my workflows and cron processes, so to help narrow down where my problem is, I could really use some confirmation about this question…. Q - If I only update the IPTC keyword data of the original image in my synced (local) folder, would that enough to make folder sync do its thing and import the updated file? If so (and off topic now I guess), how to get Gallery3 to update its tags to show the updated IPTC info? Thanks! Peter |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
Folder Sync saves filename, file modified date, and md5 hash of the content of the file. So if any of these parameters are changed on the original file, it will be processed by Folder Sync. As for IPTC keywords, I am not really sure: I am using built-in Gallery functions to update the file, so Gallery is set to process keywords, then it should work. |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
I spoke too soon: if you use built-in "tags" module, then that module doesn't implement "item_updated" event handler (only "item_created"), so hew tags would not be added/updated. |
|
wink_wink
Joined: 2012-10-24
Posts: 10 |
![]() |
Oki - thanks for the confirmation. At least I know I'm moving in the right direction now. Thanks again. |
|
floridave
![]()
Joined: 2003-12-22
Posts: 27300 |
![]() |
siburny, Dave _____________________________________________ |
|
siburny
Joined: 2012-03-27
Posts: 55 |
![]() |
Just added more information: judging by the amount of open tickets, I will try to tackle it myself probably. |
|
zahaim
Joined: 2013-08-01
Posts: 6 |
![]() |
Hello everybody, While running cron.php on my QNAP NAS as a 'httpdusr' I got the following message: Warning: flock() expects parameter 1 to be resource, boolean given in /share/HDA_DATA/Web/gallery3/modules/folder_sync/cron.php on line 5 When running it as a 'admin' this is what appears: Kohana_PHP_Exception [ 2 ]: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead Notice: Undefined offset: 1 in /share/HDA_DATA/Web/gallery3/system/libraries/I18n.php on line 60 Fatal error: Uncaught exception 'Kohana_PHP_Exception' with message 'Undefined offset: 1' in /share/HDA_DATA/Web/gallery3/system/libraries/I18n.php:60 gallery3 Installed without any issues, module as well, running with php... Thx and cheers, |
|