Explorar o código

Fixed Directory Creation if Doesn't Exist

own3mall %!s(int64=7) %!d(string=hai) anos
pai
achega
3ee94d85d7
Modificáronse 1 ficheiros con 9 adicións e 3 borrados
  1. 9 3
      OGP/ogp_agent.pl

+ 9 - 3
OGP/ogp_agent.pl

@@ -1723,11 +1723,17 @@ sub check_b4_chdir
 	{
 		logger "$path does not exist yet. Trying to create it...";
 
-		if (!mkpath($path))
+		eval { mkpath($path); 1 } or logger "Error creating $path with Perl mkpath command. Errno: $! - Trying again with sudo...";
+
+		if (!-e $path)
 		{
-			logger "Error creating $path . Errno: $!";
-			return -1;
+			sudo_exec_without_decrypt('mkdir -p ' . $path);
 		}
+		
+		if (!-e $path)
+		{
+			return -1;
+		}		
 	}
 	
 	if (!chdir $path)