fix typo, add lock file

This commit is contained in:
Laura Hausmann 2019-10-10 13:14:04 +02:00
parent d30b122c6f
commit c3aabf6f5a
2 changed files with 20 additions and 1 deletions

View file

@ -13,8 +13,19 @@ namespace repomgr
public static class Program public static class Program
{ {
public static RepoMgr Repo; public static RepoMgr Repo;
public static void Main(string[] args) public static void Main(string[] args)
{ {
if (File.Exists("/tmp/repomgr.lock"))
{
Console.WriteLine("/tmp/repomgr.lock exists, delete if you are sure that this is the only instance");
Environment.Exit(1);
}
else
{
File.Create("/tmp/repomgr.lock");
}
if (args.Length < 2 || args[1].Equals("help")) if (args.Length < 2 || args[1].Equals("help"))
PrintHelp(); PrintHelp();
Repo = new RepoMgr(args[0]); Repo = new RepoMgr(args[0]);
@ -36,6 +47,7 @@ namespace repomgr
{ {
Console.WriteLine("Init failed with error: " + e); Console.WriteLine("Init failed with error: " + e);
} }
break; break;
case "add": case "add":
if (args.Length != 3) if (args.Length != 3)
@ -48,6 +60,7 @@ namespace repomgr
{ {
Console.WriteLine("Add failed with error: " + e); Console.WriteLine("Add failed with error: " + e);
} }
break; break;
case "update": case "update":
if (args.Length < 3 || args.Length > 4) if (args.Length < 3 || args.Length > 4)
@ -71,6 +84,7 @@ namespace repomgr
{ {
Console.WriteLine("Build failed with error: " + e); Console.WriteLine("Build failed with error: " + e);
} }
break; break;
case "update-all": case "update-all":
if (args.Length != 2) if (args.Length != 2)
@ -83,6 +97,7 @@ namespace repomgr
{ {
Console.WriteLine("BuildAll failed with error: " + e); Console.WriteLine("BuildAll failed with error: " + e);
} }
break; break;
case "remove": case "remove":
if (args.Length != 3) if (args.Length != 3)
@ -95,6 +110,7 @@ namespace repomgr
{ {
Console.WriteLine("Remove failed with error: " + e); Console.WriteLine("Remove failed with error: " + e);
} }
break; break;
case "list": case "list":
if (args.Length != 2) if (args.Length != 2)
@ -107,11 +123,14 @@ namespace repomgr
{ {
Console.WriteLine("List failed with error " + e); Console.WriteLine("List failed with error " + e);
} }
break; break;
default: default:
PrintHelp(); PrintHelp();
break; break;
} }
File.Delete("/tmp/repomgr.lock");
} }
private static void PrintHelp() private static void PrintHelp()

View file

@ -205,7 +205,7 @@ namespace repomgr
} }
catch (IOException) catch (IOException)
{ {
throw new Exception("Unable to write configuratoin. Check permissions."); throw new Exception("Unable to write configuration. Check permissions.");
} }
} }
private bool CheckPackage(string package) private bool CheckPackage(string package)