[mythtv-commits] Ticket #10151: mythzoneminder and zoneminder > 1.23, x leads to broken paths

MythTV noreply at mythtv.org
Fri Nov 4 22:38:42 UTC 2011


#10151: mythzoneminder and zoneminder > 1.23,x leads to broken paths
-----------------------------------------+---------------------
     Reporter:  dscoular@…               |      Owner:  paulh
         Type:  Bug Report - General     |     Status:  new
     Priority:  major                    |  Milestone:  unknown
    Component:  Plugin - MythZoneminder  |    Version:  0.24.1
     Severity:  high                     |   Keywords:
Ticket locked:  0                        |
-----------------------------------------+---------------------
 Hi,
 I just recompiled zoneminder 1.24.4 via:

 {{{
 ./configure --sysconfdir=/etc/zm --prefix=/usr --mandir=/usr/share/man
 --infodir=/usr/share/info --with-mysql=/usr  --with-
 webdir=/usr/share/zoneminder --with-ffmpeg=/usr --with-cgidir=/usr/lib
 /cgi-bin --with-webuser=www-data --with-webgroup=www-data --enable-
 crashtrace=no --enable-mmap=no
 make;make install
 }}}

 In order to get shared memory back as recommended in the MythTV wiki for
 mythzoneminder.

 However, the path to event images is now of the form:

 /usr/share/zoneminder/events/1/11/11/05/.2860/001-capture.jpg

 rather than the old 1.22.x path that mythzoneminder is looking for event
 images in:

 /usr/share/zoneminder/events/1/2867/023-analyse.jpg

 This means that all access to historical events is broken when using
 mythzoneminder and zoneminder > 1.23.x (I haven't test versions between
 1.22.x and 1.24.4 but this is based on comments in the changelog).

 I think this is due to the zoneminder config variable now defaulting to
 ZM_USE_DEEP_STORAGE. However, even changing the default for this produces
 an event id prefixed by a "." and uses the word "capture" instead of
 "analysis" in the jpg filename.

 mythzmserver uses the following logic (I think) to find event images:

 {{{
     filepath = g_webPath + "/events/" + monitorID + "/" + eventID + "/";
     sprintf(str, m_eventFileFormat.c_str(), frameNo);
     filepath += str;
 }}}

 Whereas, the zoneminder code to build the path appears to be in
 http://svn.zoneminder.com/svn/zm/trunk/src/zm_event.cpp and uses the
 following logic:

 {{{
     if ( config.use_deep_storage )
     {
         char *path_ptr = path;
         path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d",
 config.dir_events, monitor->Id() );

         int dt_parts[6];
         dt_parts[0] = stime->tm_year-100;
         dt_parts[1] = stime->tm_mon+1;
         dt_parts[2] = stime->tm_mday;
         dt_parts[3] = stime->tm_hour;
         dt_parts[4] = stime->tm_min;
         dt_parts[5] = stime->tm_sec;

         char date_path[PATH_MAX] = "";
         char time_path[PATH_MAX] = "";
         char *time_path_ptr = time_path;
         for ( int i = 0; i < sizeof(dt_parts)/sizeof(*dt_parts); i++ )
         {
             path_ptr += snprintf( path_ptr, sizeof(path)-(path_ptr-path),
 "/%02d", dt_parts[i] );

             struct stat statbuf;
             errno = 0;
             stat( path, &statbuf );
             if ( errno == ENOENT || errno == ENOTDIR )
             {
                 if ( mkdir( path, 0755 ) )
                 {
                     Fatal( "Can't mkdir %s: %s", path, strerror(errno));
                 }
             }
             if ( i == 2 )
                 strncpy( date_path, path, sizeof(date_path) );
             else if ( i >= 3 )
                 time_path_ptr += snprintf( time_path_ptr, sizeof(time_path
 )-(time_path_ptr-time_path), "%s%02d", i>3?"/":"", dt_parts[i] );
         }
         char id_file[PATH_MAX];
         // Create event id symlink
         snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id );
         if ( symlink( time_path, id_file ) < 0 )
             Fatal( "Can't symlink %s -> %s: %s", id_file, path,
 strerror(errno));
         // Create empty id tag file
         snprintf( id_file, sizeof(id_file), "%s/.%d", path, id );
         if ( FILE *id_fp = fopen( id_file, "w" ) )
             fclose( id_fp );
         else
             Fatal( "Can't fopen %s: %s", id_file, strerror(errno));
     }
     else
     {
         snprintf( path, sizeof(path), "%s/%d/%d", config.dir_events,
 monitor->Id(), id );

         struct stat statbuf;
         errno = 0;
         stat( path, &statbuf );
         if ( errno == ENOENT || errno == ENOTDIR )
         {
             if ( mkdir( path, 0755 ) )
             {
                 Error( "Can't mkdir %s: %s", path, strerror(errno));
             }
         }
         char id_file[PATH_MAX];
         // Create empty id tag file
         snprintf( id_file, sizeof(id_file), "%s/.%d", path, id );
         if ( FILE *id_fp = fopen( id_file, "w" ) )
             fclose( id_fp );
         else
             Fatal( "Can't fopen %s: %s", id_file, strerror(errno));
     }
     last_db_frame = 0;
 }
 }}}

 I suspect that mythzoneminder must adopt a similar logic if it is to be
 compatible with mythzoneminder >= 1.23.x.

 As always, I could be wrong and perhaps there is a simple config change
 I'm overlooking. Any help much appreciated.

 Cheers,

 Doug

 "The big print giveth and the small print taketh away"

-- 
Ticket URL: <http://code.mythtv.org/trac/ticket/10151>
MythTV <http://code.mythtv.org/trac>
MythTV Media Center


More information about the mythtv-commits mailing list