hello to all,
i have a code that composes millions of small files into tar archives, and therefore i decided to use the /tmp folder of my solaris machine.
here is what i did to accomplish the mission :
first i tried to create tar archive in /tmp and then move to the target diriectory, but when i do so, during the tar process, i can see the tar file in /tmp folder, however when i check the existence of the file in /tmp it gave me a file not found exception.. what really weird is that even it couldnt find the tar file there, it could move the tar file to destination even though the move command lines should work after the file existence check.. then i decided to check the moved file, but it couldnt find the existence of the tar file in the destination neither.
then i tried to create the tar file right in the destination directory, but the same happens there too. even the file is there, the File.exists() returns false. can anyone suggest any solution or idea about why it happens and how i can solve this problem? thanks to all.
below is the final code of my tryings.. :
when it comes to the line of the method czf.take_md5(tarName), it says no such file or directory.
public static synchronized void CreateZipFileFromSingleFolder(String folder,int CDNumber) throws Exception{ CreateZipFile czf = new CreateZipFile(); System.err.println(folder + " tarlaniyor..."); Process p=null; String tarName=CDFolderInfo.getID()+"_cd_"+CDNumber + ".tar "; String tarFolder=CDFolderInfo.getPathRoot(); //String komut = "tar -cf " + tarFolder+"/"+tarName+" "+ folder; String komut = "tar -cf " + "/opt/dist/dist1/cdrepo/"+tarName+" "+ folder; try { System.err.println(komut + " komutu ile tarlama yapilacak......."); p = Runtime.getRuntime().exec(komut); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { p.waitFor(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.err.println("system exit value: " + p.exitValue()); if(p.exitValue()==0) { //System.err.println("tar file existence will be checked.."); File f=new File("/opt/dist/dist1/cdrepo/"+tarName); boolean fileExists = FileUtils.waitFor(f, 10); if(fileExists){ System.err.println("tar succeeded .... " + tarFolder+"/"+tarName); System.err.println("tar file existence PASSED .."); }else{ System.err.println("tar process didnt fail, but actually failed..."); } f=null; /*p2 = Runtime.getRuntime().exec("mv " + tarFolder+"/"+tarName+" "+ "cdrepo/"+tarName); p2.waitFor(); if(p2.exitValue()==0){ File f2=new File("cdrepo/"+tarName); if(f2.exists()) System.err.println("Tar tasima succeed.."); f2=null; }else System.err.println("Tar tasima failed..");*/ try { czf.take_md5("/opt/dist/dist1/cdrepo/"+tarName); System.err.println("MD5 alma succeed..."); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } Process p1=null; try { p1 = Runtime.getRuntime().exec("rm -rf " + folder ); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { p1.waitFor(); if(p1.exitValue()==0) System.err.println("Dizin silme tamamlandı... " + folder); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }