Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 111990 | Differences between
and this patch

Collapse All | Expand All

(-)gnump3d-index.orig (-86 lines)
Lines 88-94 Link Here
88
# Global variables.
88
# Global variables.
89
#
89
#
90
my $root     = "" ;
90
my $root     = "" ;
91
my $lockfile = "" ;
92
my $cache    = "" ;
91
my $cache    = "" ;
93
my %cache;
92
my %cache;
94
93
Lines 96-108 Link Here
96
95
97
96
98
#
97
#
99
#  Make sure that signals cause our END segment to run
100
# so that our lockfile is removed on abnormal termination.
101
#
102
use sigtrap qw(die normal-signals error-signals);
103
104
105
#
106
#  Parse the command line arguments.
98
#  Parse the command line arguments.
107
#
99
#
108
&parseArguments();
100
&parseArguments();
Lines 134-143 Link Here
134
{
126
{
135
  $root = &getConfig( "root",      "/home/mp3" ); 
127
  $root = &getConfig( "root",      "/home/mp3" ); 
136
}
128
}
137
if ( !length( $lockfile ) )
138
{
139
  $lockfile = &getConfig( "lockfile",  "/tmp/index.lok" );
140
}
141
if ( !length( $cache ) )
129
if ( !length( $cache ) )
142
{
130
{
143
  $cache    = &getConfig( "tag_cache", "/tmp/tags.cache" );
131
  $cache    = &getConfig( "tag_cache", "/tmp/tags.cache" );
Lines 164-191 Link Here
164
152
165
153
166
#
154
#
167
# Test for a lockfile indicating that we're already running.
168
#
169
if ( &lockPresent() )
170
{
171
    print "gnump3d-index appears to be already running.\n";
172
    print "if this is in error remove the lockfile $lockfile\n";
173
    exit;
174
}
175
176
177
#
178
# Create our lock file.
179
&createLock();
180
181
182
#
183
# Sanity check the code.
155
# Sanity check the code.
184
#
156
#
185
if ( ! -e $root )
157
if ( ! -e $root )
186
{
158
{
187
    print "The server root directory you are trying to index '$root' doesn't exist.\n";
159
    print "The server root directory you are trying to index '$root' doesn't exist.\n";
188
    &removeLock();
189
    exit;
160
    exit;
190
}
161
}
191
162
Lines 372-384 Link Here
372
343
373
    foreach my $file ( sort @FOUND )
344
    foreach my $file ( sort @FOUND )
374
    {
345
    {
375
	#
376
	# Update our progress count every ten tracks.
377
	if ( ( $count % 10 ) == 0 )
378
	{
379
	    &updateLock( $count, $total );
380
	}
381
382
        # If we looked for an old cache file, and it existed, we can now
346
        # If we looked for an old cache file, and it existed, we can now
383
        # look to see if the mtime in the cache is the same as the mtime
347
        # look to see if the mtime in the cache is the same as the mtime
384
        # of the file.  If they are the same, trust the cache.
348
        # of the file.  If they are the same, trust the cache.
Lines 475-519 Link Here
475
    close( OUT );
439
    close( OUT );
476
}
440
}
477
441
478
#
479
#  Test to see if our lockfile is present.
480
sub lockPresent( )
481
{
482
    return( -e $lockfile );
483
}
484
485
#
486
#  Unconditionally remove our lock file.
487
sub removeLock( )
488
{
489
    unlink( $lockfile );
490
}
491
492
#
493
#  Update our lockfile with the current progress count.
494
sub updateLock( )
495
{
496
    my ( $cur, $total ) = ( @_ );
497
    my $PER = ( ( $total - $cur  ) / $total ) * 100.0;
498
    if ( $PER =~ /([0-9]+)\.([0-9]+)/ )
499
    {
500
    	$PER = $1;
501
    }
502
    open( LOK, ">$lockfile" );
503
    print LOK "Processing file $cur of $total ( \%$PER remaining )\n";
504
    close( LOK );
505
506
}
507
508
#
509
# Create our lockfile.
510
sub createLock(  )
511
{
512
    open( LOK, ">>$lockfile" );
513
    close( LOK );
514
}
515
516
517
442
518
#
443
#
519
#  Parse the command line options.
444
#  Parse the command line options.
Lines 523-529 Link Here
523
	       "config=s", \$CONFIG_FILE,
448
	       "config=s", \$CONFIG_FILE,
524
	       "debug",    \$DEBUG,
449
	       "debug",    \$DEBUG,
525
               "help",     \$SHOW_HELP,
450
               "help",     \$SHOW_HELP,
526
	       "lock=s",   \$lockfile,
527
	       "output=s", \$cache,
451
	       "output=s", \$cache,
528
	       "root=s",   \$root,
452
	       "root=s",   \$root,
529
	       "stats",    \$SHOW_STATS,
453
	       "stats",    \$SHOW_STATS,
Lines 553-559 Link Here
553
Options:
477
Options:
554
    --config file      The configuration file to read.
478
    --config file      The configuration file to read.
555
    --help             Show this help.
479
    --help             Show this help.
556
    --lock file        Use the given lockfile rather than the default.
557
    --output file      Write the output to the given file.
480
    --output file      Write the output to the given file.
558
    --root directory   Start the indexing at the given directory.
481
    --root directory   Start the indexing at the given directory.
559
    --stats            Don't update the cache file, just display audio stats.
482
    --stats            Don't update the cache file, just display audio stats.
Lines 610-621 Link Here
610
  }
533
  }
611
  close( CACHE );
534
  close( CACHE );
612
}
535
}
613
614
615
#
616
#  This section of code always runs when the script terminates.
617
#
618
END
619
{
620
	&removeLock();
621
}

Return to bug 111990