tags 643305 + wontfix
notforwarded 643305
forwarded 646031 http://code.google.com/p/theunarchiver/issues/detail?id=397
tags 646031 + patch
thanks
On Thu, Oct 20, 2011 at 08:00:18PM +0200, Jakub Wilk wrote:
> Package: theunarchiver
> When I unpack RAR archives with unar, it creates
> $HOME/GNUstep/Library directory:
> I wish it didn't clutter my home directory with useless directories...
This directory is not useless, and gnustep-base makes sure to create
it as many methods rely on its existence. In this case, unar is not
using it directly or accessing the defaults database, but it uses the
NSDate class, which needs to check the timezone upon initialization,
which in turn uses NSUserDefaults to retrieve any user-defined one,
etc, etc.
In theory, with some effort it could be possible to eradicate this
behaviour as it really smells like bad design, but right now I have
more important problems at hand than having a discussion with upstream
regarding this minor issue.
If you wonder why the directory is not hidden, it is because GNUstep
software is installed there in the USER domain.
The attached patch should do the desired cleanup, but:
- Please test extensively, it is potentially dangerous.
- There could be a race condition in the unlikely case that the same
user is running `unar' and another GNUstep program simultaneously.
- It uses a GNUstep-specific function, so should be wrapped in
appropriate conditionals (#ifdef GNUSTEP...) if the same code is
compiled/run on Muck OS X.
--- theunarchiver-2.7.1.orig/XADMaster/unar.m
+++ theunarchiver-2.7.1/XADMaster/unar.m
@@ -133,7 +133,23 @@ fileFraction:(double)fileprogress estima
@end
-
+/* Helper function to delete ~/GNUstep if it is created as a side
+ effect of using unar. */
+void
+cleanup (void)
+{
+ NSFileManager *mgr;
+ NSString *dir;
+ NSArray *paths;
+
+ mgr = [NSFileManager defaultManager];
+ dir = [GSDefaultsRootForUser (NSUserName ())
+ stringByDeletingLastPathComponent];
+ paths = [mgr subpathsAtPath: dir];
+ if ([paths count] == 1
+ && [[NSString pathWithComponents: paths] isEqualToString: @"Library"])
+ [mgr removeFileAtPath: dir handler: nil];
+}
int main(int argc,const char **argv)
@@ -278,6 +294,7 @@ int main(int argc,const char **argv)
[pool release];
}
+ cleanup ();
[pool release];
return 0;