mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-23 20:01:02 +00:00
Fix error sweeping for compress/delete ... track times in Log and DebugLog
directories separately. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@38644 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
04b2fa4a4d
commit
ab4c6bd8fe
1 changed files with 37 additions and 19 deletions
56
EcCommand.m
56
EcCommand.m
|
@ -137,8 +137,10 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
unsigned revSequence;
|
unsigned revSequence;
|
||||||
float nodesFree;
|
float nodesFree;
|
||||||
float spaceFree;
|
float spaceFree;
|
||||||
NSTimeInterval uncompressed;
|
NSTimeInterval debUncompressed;
|
||||||
NSTimeInterval undeleted;
|
NSTimeInterval debUndeleted;
|
||||||
|
NSTimeInterval logUncompressed;
|
||||||
|
NSTimeInterval logUndeleted;
|
||||||
BOOL sweeping;
|
BOOL sweeping;
|
||||||
}
|
}
|
||||||
- (NSFileHandle*) openLog: (NSString*)lname;
|
- (NSFileHandle*) openLog: (NSString*)lname;
|
||||||
|
@ -1764,8 +1766,10 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
ecSetLogsSubdirectory(@"Logs");
|
ecSetLogsSubdirectory(@"Logs");
|
||||||
if (nil != (self = [super initWithDefaults: defs]))
|
if (nil != (self = [super initWithDefaults: defs]))
|
||||||
{
|
{
|
||||||
uncompressed = 0.0;
|
debUncompressed = 0.0;
|
||||||
undeleted = 0.0;
|
debUndeleted = 0.0;
|
||||||
|
logUncompressed = 0.0;
|
||||||
|
logUndeleted = 0.0;
|
||||||
nodesFree = 0.1;
|
nodesFree = 0.1;
|
||||||
spaceFree = 0.1;
|
spaceFree = 0.1;
|
||||||
|
|
||||||
|
@ -2441,11 +2445,11 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
|
|
||||||
mgr = [NSFileManager defaultManager];
|
mgr = [NSFileManager defaultManager];
|
||||||
|
|
||||||
if (0.0 == undeleted)
|
if (0.0 == debUndeleted)
|
||||||
{
|
{
|
||||||
undeleted = now - 365.0 * day;
|
debUndeleted = now - 365.0 * day;
|
||||||
}
|
}
|
||||||
ti = undeleted;
|
ti = debUndeleted;
|
||||||
latestDeleteAt = now - day * deleteAfter;
|
latestDeleteAt = now - day * deleteAfter;
|
||||||
while (nil == gone && ti < latestDeleteAt)
|
while (nil == gone && ti < latestDeleteAt)
|
||||||
{
|
{
|
||||||
|
@ -2460,21 +2464,24 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
}
|
}
|
||||||
ti += day;
|
ti += day;
|
||||||
}
|
}
|
||||||
undeleted = ti;
|
debUndeleted = ti;
|
||||||
RETAIN(gone);
|
RETAIN(gone);
|
||||||
DESTROY(arp);
|
DESTROY(arp);
|
||||||
return AUTORELEASE(gone);
|
return AUTORELEASE(gone);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _sweep: (NSString*)logs at: (NSCalendarDate*)when
|
- (void) _sweep: (BOOL)deb at: (NSCalendarDate*)when
|
||||||
{
|
{
|
||||||
NSInteger compressAfter;
|
NSInteger compressAfter;
|
||||||
NSInteger deleteAfter;
|
NSInteger deleteAfter;
|
||||||
|
NSTimeInterval uncompressed;
|
||||||
|
NSTimeInterval undeleted;
|
||||||
NSTimeInterval latestCompressAt;
|
NSTimeInterval latestCompressAt;
|
||||||
NSTimeInterval latestDeleteAt;
|
NSTimeInterval latestDeleteAt;
|
||||||
NSTimeInterval now;
|
NSTimeInterval now;
|
||||||
NSTimeInterval ti;
|
NSTimeInterval ti;
|
||||||
NSFileManager *mgr;
|
NSFileManager *mgr;
|
||||||
|
NSString *dir;
|
||||||
NSString *file;
|
NSString *file;
|
||||||
NSAutoreleasePool *arp;
|
NSAutoreleasePool *arp;
|
||||||
|
|
||||||
|
@ -2500,6 +2507,19 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
|
|
||||||
mgr = [[NSFileManager new] autorelease];
|
mgr = [[NSFileManager new] autorelease];
|
||||||
|
|
||||||
|
dir = [self ecUserDirectory];
|
||||||
|
if (YES == deb)
|
||||||
|
{
|
||||||
|
dir = [dir stringByAppendingPathComponent: @"DebugLogs"];
|
||||||
|
uncompressed = debUncompressed;
|
||||||
|
undeleted = debUndeleted;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir = [dir stringByAppendingPathComponent: @"Logs"];
|
||||||
|
uncompressed = logUncompressed;
|
||||||
|
undeleted = logUndeleted;
|
||||||
|
}
|
||||||
if (0.0 == undeleted)
|
if (0.0 == undeleted)
|
||||||
{
|
{
|
||||||
undeleted = now - 365.0 * day;
|
undeleted = now - 365.0 * day;
|
||||||
|
@ -2511,7 +2531,7 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
|
|
||||||
when = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate: ti];
|
when = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate: ti];
|
||||||
file = [[logs stringByAppendingPathComponent:
|
file = [[dir stringByAppendingPathComponent:
|
||||||
[when descriptionWithCalendarFormat: @"%Y-%m-%d"]]
|
[when descriptionWithCalendarFormat: @"%Y-%m-%d"]]
|
||||||
stringByStandardizingPath];
|
stringByStandardizingPath];
|
||||||
if ([mgr fileExistsAtPath: file])
|
if ([mgr fileExistsAtPath: file])
|
||||||
|
@ -2521,7 +2541,8 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
ti += day;
|
ti += day;
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
undeleted = ti;
|
if (YES == deb) debUndeleted = ti;
|
||||||
|
else logUndeleted = ti;
|
||||||
|
|
||||||
if (uncompressed < undeleted)
|
if (uncompressed < undeleted)
|
||||||
{
|
{
|
||||||
|
@ -2537,7 +2558,7 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
NSString *base;
|
NSString *base;
|
||||||
|
|
||||||
when = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate: ti];
|
when = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate: ti];
|
||||||
base = [[logs stringByAppendingPathComponent:
|
base = [[dir stringByAppendingPathComponent:
|
||||||
[when descriptionWithCalendarFormat: @"%Y-%m-%d"]]
|
[when descriptionWithCalendarFormat: @"%Y-%m-%d"]]
|
||||||
stringByStandardizingPath];
|
stringByStandardizingPath];
|
||||||
if ([mgr fileExistsAtPath: base isDirectory: &isDirectory] == NO
|
if ([mgr fileExistsAtPath: base isDirectory: &isDirectory] == NO
|
||||||
|
@ -2621,7 +2642,8 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
ti += day;
|
ti += day;
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
uncompressed = ti;
|
if (YES == deb) debUncompressed = ti;
|
||||||
|
else logUncompressed = ti;
|
||||||
|
|
||||||
DESTROY(arp);
|
DESTROY(arp);
|
||||||
sweeping = NO;
|
sweeping = NO;
|
||||||
|
@ -2634,16 +2656,12 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
*/
|
*/
|
||||||
- (void) sweep: (NSCalendarDate*)when
|
- (void) sweep: (NSCalendarDate*)when
|
||||||
{
|
{
|
||||||
NSString *logs;
|
|
||||||
|
|
||||||
if (nil == when)
|
if (nil == when)
|
||||||
{
|
{
|
||||||
when = [NSDate date];
|
when = [NSDate date];
|
||||||
}
|
}
|
||||||
logs = [[self ecUserDirectory] stringByAppendingPathComponent: @"DebugLogs"];
|
[self _sweep: YES at: when];
|
||||||
[self _sweep: logs at: when];
|
[self _sweep: NO at: when];
|
||||||
logs = [[self ecUserDirectory] stringByAppendingPathComponent: @"Logs"];
|
|
||||||
[self _sweep: logs at: when];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) ecNewHour: (NSCalendarDate*)when
|
- (void) ecNewHour: (NSCalendarDate*)when
|
||||||
|
|
Loading…
Reference in a new issue