Module: Folder Sync
siburny
Joined: 2012-03-27
Posts: 55 |
Posted: Mon, 2012-10-15 18:29 |
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 |
|
Posts: 8
Hey,
Thank you for this great module, can you my last two posts here:
http://gallery.menalto.com/node/109168
Also it would be great if you can add a feature letting user specify an album for synchronized images.
Posts: 55
I will update the file to fix the E_STRICT warning.
As for the timezone, it's not something that module can fix: it was a particular setup issue with your server.
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:
Change 1 to the album_id of desired container album (album_id #1 is the root album)
Posts: 23
I've got everything working correctly - as far as importing goes. However, delete doesn't work - is the feature fully implemented?
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.
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
/Volumes/DataRAID/mysite.com/system/libraries/ORM_Validation_Exception.php [ 20 ]
#0 /Volumes/DataRAID/mysite.com/modules/videos/models/item.php(82): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 /Volumes/DataRAID/mysite.com/modules/folder_sync/controllers/folder_sync.php(266): Item_Model_Core->delete()
#2 /Volumes/DataRAID/mysite.com/modules/folder_sync/cron.php(63): Folder_Sync_Controller::cron()
#3 {main}
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?
Posts: 23
Would be more than happy to help - what do I need to do?
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?
Posts: 55
Never mind: in my installation that file is in different location. Here is the relevant code:
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
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
/Volumes/DataRAID/site.com/system/libraries/ORM_Validation_Exception.php [ 20 ]
#0 /Volumes/DataRAID/site.com/modules/videos/models/item.php(82): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 /Volumes/DataRAID/site.com/modules/folder_sync/controllers/folder_sync.php(266): Item_Model_Core->delete()
#2 /Volumes/DataRAID/site.com/modules/folder_sync/cron.php(63): Folder_Sync_Controller::cron()
#3 {main}
Posts: 55
Oh stupid me: it should be " && $entry->item_id > 1" like that:
https://github.com/siburny/gallery3/commit/28964f7da3cec7dd8ed3982abd085d68cdb99b3f
Posts: 23
Working perfectly now! Thanks so much!
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:
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.
However I needed it to run it a few times because I kept hitting the time limit or number limit. now when I run it, I get the following error:
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.
Posts: 5
$_SERVER is not being populated
I get:
error: load_user Exception: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent
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.
although when i execute it via shell, it works fine
Posts: 1
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
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!
Posts: 3
Thank you for great module!
Can't get it working.
My photos folder looks like this:
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.
There are no day of month folders in monthes albums and photos in it.
Is there any way to fix this? Thank you.
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
/media/Megadata/var/www/data/gallery.***.net/html/system/libraries/ORM_Validation_Exception.php [ 20 ]
#0 /media/Megadata/var/www/data/gallery.***.net/html/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation('items', Object(Valida$
#1 /media/Megadata/var/www/data/gallery.***.net/html/modules/gallery/models/item.php(773): ORM_Core->validate(NULL)
#2 /media/Megadata/var/www/data/gallery.***.net/html/system/libraries/ORM.php(778): Item_Model_Core->validate()
#3 /media/Megadata/var/www/data/gallery.***.net/html/modules/gallery/libraries/MY_ORM.php(34): ORM_Core->save()
#4 /media/Megadata/var/www/data/gallery.***.net/html/modules/gallery/libraries/ORM_MPTT.php(76): ORM->save()
#5 /media/Megadata/var/www/data/gallery.***.net/html/modules/gallery/models/item.php(367): ORM_MPTT_Core->save()
#6 /media/Megadata/var/www/data/gallery.***.net/html/modules/folder_sync/controllers/folder_sync.php(169): Item_Model_Core->save()
#7 /media/Megadata/var/www/data/gallery.***.net/html/modules/folder_sync/cron.php(63): Folder_Sync_Controller::cron()
#8 {main}
2013-01-05 11:10:02 +00:00 --- error: Validation errors: Array
(
[name] => illegal_data_file_extension
)
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
Unknown [ 0 ]
#0 [internal function]: Kohana_PHP_Exception_Core::shutdown_handler(NULL)
#1 /media/Megadata/var/www/data/gallery.***.net/html/system/core/Event.php(208): call_user_func_array(Array, Array)
#2 /media/Megadata/var/www/data/gallery.***.net/html/system/core/Kohana.php(553): Event_Core::run('system.shutdown')
#3 [internal function]: Kohana_Core::shutdown()
#4 {main}
Posts: 3
Never mind. 255 master-branch code solved my problem. Thank you for the excellent module!
Posts: 55
I will do a quick test to see what might be happening here ...
[update]
So after some testing, it works fine on a brand new installation, but it doesn't work in the case, where cron job was previously run. When a cronjob is run first time, it creates a placeholder in the database which points to a target root folder for the cronjob. In that case, you have to manually update a record in "folder_sync" table (you have to look for a record that has parent_id set to NULL) or alternatively you can delete ALL records (but it has its own repercussions).
Posts: 55
@Hdi Glad it worked for you!
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:
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.
Posts: 2
Thank you siburny for the plugin.
By mistake I have deleted folder_sync database from mysql.
What can I do to reinstali the plugin?
Posts: 2
I did help myself. It works great.
Posts: 55
@spags Will update the code with your suggestions.
@arturmaj Glad all worked out.
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.
This is my system (uname -a): Linux mythbox 3.2.0-34-generic-pae #53-Ubuntu SMP Thu Nov 15 11:11:12 UTC 2012 i686 athlon i386 GNU/Linux
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
ORM_Validation_Exception [ 44 ]: ORM Validation has failed for items model
/var/www/gallery3/system/libraries/ORM_Validation_Exception.php [ 20 ]
#0 /var/www/gallery3/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 /var/www/gallery3/modules/gallery/models/item.php(773): ORM_Core->validate(NULL)
#2 /var/www/gallery3/system/libraries/ORM.php(778): Item_Model_Core->validate()
#3 /var/www/gallery3/modules/gallery/libraries/MY_ORM.php(34): ORM_Core->save()
#4 /var/www/gallery3/modules/gallery/libraries/ORM_MPTT.php(76): ORM->save()
#5 /var/www/gallery3/modules/gallery/models/item.php(367): ORM_MPTT_Core->save()
#6 /var/www/gallery3/modules/folder_sync/controllers/folder_sync.php(214): Item_Model_Core->save()
#7 /var/www/gallery3/modules/folder_sync/cron.php(63): Folder_Sync_Controller::cron()
#8 {main}
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.
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.
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
(
[name] => illegal_data_file_extension
)
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 ]
15 * @param Validation $array
16 * @return
17 */
18 public static function handle_validation($table, Validation $array)
19 {
20 $exception = new ORM_Validation_Exception('ORM Validation has failed for :table model',array(':table'=>$table));
21 $exception->validation = $array;
22 throw $exception;
23 }
24 } // End ORM_Validation_Exception
Is this helpful?
Thanks.
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?
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.
Posts: 55
Yeah! I really need to add some exception trapping and handling to make our lives easier
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".
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.
Posts: 1
I just wanted to say thank you for the folder_sync module.
I've just donated 20$ to the Gallery project.
We'll also be looking how to integrate gallery into wordpress
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
________________________________
All New jQuery Minislideshow for G2/G3
Posts: 7
I'm feeling very stupid. I can't figure out how to down load the module. Running it will be another issue.
What is git and how do I get the module onto my server? I understand zip files and the like but git????
Help get me past first base please.
Thanks
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.
The web pages are from /home/www/gallery3/
Thanks
www@theanswer:~/gallery3/modules/folder_sync$ ./cron.php
: No such file or directory
: command not found
./cron.php: line 3: //: is a directory
./cron.php: line 4: syntax error near unexpected token `('
./cron.php: line 4: `@$fp = fopen(sys_get_temp_dir().DIRECTORY_SEPARATOR."galler'.lock", "w+");
www@theanswer:~/gallery3/modules/folder_sync$
Posts: 138
Try running "php cron.php" instead of "./cron.php"
Posts: 7
That was it. Thank You very much.
I should have known that but...
Thanks again
Stu
Posts: 55
Make sure you run as apache user to prevent permissions problem.
Posts: 55
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
Posts: 7
Thanks
got it.
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!
(I'm learning ok?!)
Peter
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.
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.
Posts: 10
Oki - thanks for the confirmation. At least I know I'm moving in the right direction now.
Thanks again.
Cheers,
Peter
Posts: 27300
siburny,
the tags module is being updated for G3.1 so perhaps you can add some more deatils to the ticket I just created:
https://sourceforge.net/apps/trac/gallery/ticket/2076
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 55
Just added more information: judging by the amount of open tickets, I will try to tackle it myself probably.
Posts: 6
Hello everybody,
I am newbie in php and I don't manage to figure out what I did wrong.
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
Couldn't get the lock!
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
/share/HDA_DATA/Web/gallery3/modules/gallery/config/locale.php [ 36 ]
#0 [internal function]: Kohana_PHP_Exception_Core::error_handler(2, 'date_default_ti...', '/share/HDA_DATA...', 36, Array)
#1 /share/HDA_DATA/Web/gallery3/modules/gallery/config/locale.php(36): date_default_timezone_get()
#2 /share/HDA_DATA/Web/gallery3/system/libraries/drivers/Config/Array.php(70): require('/share/HDA_DATA...')
#3 /share/HDA_DATA/Web/gallery3/system/libraries/drivers/Config.php(111): Config_Array_Driver->load('locale', false)
#4 /share/HDA_DATA/Web/gallery3/system/core/Kohana_Config.php(121): Config_Driver->get('locale.language', false, false)
#5 /share/HDA_DATA/Web/gallery3/system/core/Kohana.php(385): Kohana_Config_Core->get('locale.language', false, false)
#6 /share/HDA_DATA/Web/gallery3/system/core/Kohana.php(150): Kohana_Core::config('locale.language')
#7 /share/HDA_DATA/Web/gallery3/modules/folder_sync/cron.php(59): Kohana_Core::setup()
#8 {main}
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
Stack trace:
#0 /share/HDA_DATA/Web/gallery3/system/libraries/I18n.php(60): Kohana_PHP_Exception_Core::error_handler(8, 'Undefined offse...', '/share/HDA_DATA...', 60, Array)
#1 /share/HDA_DATA/Web/gallery3/system/libraries/I18n.php(93): I18n_Core::get_text('Undefined offse...')
#2 /share/HDA_DATA/Web/gallery3/system/core/Kohana_Exception.php(42): __('Undefined offse...', NULL)
#3 /share/HDA_DATA/Web/gallery3/system/libraries/Kohana_PHP_Exception.php(60): Kohana_Exception_Core->__construct('Undefined offse...')
#4 /share/HDA_DATA/Web/gallery3/system/libraries/Kohana_PHP_Exception.php(95): Kohana_PHP_Exception_Core->__construct(8, 'Undefined offse...', '/share/HDA_DATA...', 60)
#5 [internal function]: Kohana_PHP_Exception_Core::shutdown_handler(NULL)
#6 /share/HDA_DATA/Web/gallery3/system/core/Event.php(208): call_user_func_array(Array, Array)
#7 /share/HDA_DATA/Web/gallery3 in /share/HDA_DATA/Web/gallery3/system/libraries/I18n.php on line 60
gallery3 Installed without any issues, module as well, running with php...
Any help would be very appreciated.
Thx and cheers,
Jan