Task: Detect missing folders and files

mr.xy

Joined: 2011-09-20
Posts: 66
Posted: Wed, 2011-12-21 13:51

I believe that through broken moving, deleting or other action there are a bunch of inconsistencys between database an filesystem which lead to consecutive faults.

Would like to detect those inconsistencies with a task in the maintenance-panel.

Tried this in gallery_task.php but it doesn't work:

#detects missing directories
    $tasks[] = Task_Definition::factory()
->callback("gallery_task::missing_directory")
->name(t("Detects missing directories"))
->description(t("Detects missing directories wich lead to dead database entries and inconsistency between db and filessystem."))
->severity(log::SUCCESS);


  static function missing_directory($task) {
      foreach (ORM::factory("item")->where('thumb_dirty', '=', 1)->limit(10)->find_all() as $item) {
          if($item->is_album()){
              try {
                is_dir($item->file_path());

                $errors[] = t("Direcory for '%title' exists.",
                              array("title" => html::purify($item->title)));
              } catch (Exception $e) {
                $errors[] = t("Directory for '%title' is missing.",
                              array("title" => html::purify($item->title)));
                $errors[] = (string)$e;
                $ignored[$item->id] = 1;
              }
          }elseif($item->is_photo() || $item->is_movie()) {
              try {
                is_file($item->file_path());

                $errors[] = t("Direcory for '%title' exists.",
                              array("title" => html::purify($item->title)));
              } catch (Exception $e) {
                $errors[] = t("Directory for '%title' is missing.",
                              array("title" => html::purify($item->title)));
                $errors[] = (string)$e;
                $ignored[$item->id] = 1;
              }
          }
      }
  }
 
tempg

Joined: 2005-12-17
Posts: 1633
Posted: Thu, 2011-12-22 19:59

I haven't had many problems with Gallery3, so I'm not sure, but I'm assuming that the fix Gallery task doesn't help with this?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 25965
Posted: Thu, 2011-12-22 20:56

Just a FYI: http://gallery.menalto.com/node/103239#comment-379756

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
mr.xy

Joined: 2011-09-20
Posts: 66
Posted: Thu, 2011-12-22 23:19

@temppg: I noticed, that when gallery says: "Album is not writable" it may be connected with rights which are not properly set. But in most cases there simply was no folder to write in. Warning though should better say: "Album is not writable or not existent."

I don't know which things fixing gallery does.

@floridave: The thread seems to end with the same questions I have. Looking in the code, it doesn't seem to be a difficult thing to write such a task for someone knowing the system ... For me there is a lot of time-eating guessing. But I think this task could yield a good indicator of present and further problems, regarding one of my still unsolved former thread:
http://gallery.menalto.com/node/103723

Would be glad to get some help here.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 25965
Posted: Thu, 2011-12-22 23:56

It gets beyond my ability for things I can't reproduce and my skills to troubleshoot. Bharat is on the thread and I have sent him a reminder about some threads. Perhaps he has life/work in the way at this time.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team