Przeglądaj źródła

Fixed Directory Creation if Doesn't Exist

own3mall 7 lat temu
rodzic
commit
3ee94d85d7
1 zmienionych plików z 9 dodań i 3 usunięć
  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)