Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOException insufficient disk space when accessing Citrix mounted drive

I'm having a really strange problem. I'm trying to download some file and store. My code is relatively simple and straight forward (see below) and works fine on my local machine.

But it is intended to run on a Windows Terminal Server accessed through Citrix and a VPN. The file is to be saved to a mounted network drive. This mount is the local C:\ drive mounted through the Citrix VPN, so there might be some lag involved. Unfortunately I have no inside detail about how exactly the whole infrastructure is set up...

Now my problem is that the code below throws an IOException telling me there is no space left on the disk, when attempting to execute the write() call. The directory structure is created alright and a zero byte file is created, but content is never written.

There is more than a gigabyte space available on the drive, the Citrix client has been given "Full Access" permissions and copying/writing files on that mapped drive with Windows explorer or notepad works just fine. Only Java is giving me trouble here.

I also tried downloading to a temporary file first and then copying it to the destination, but since copying is basically the same stream operation as in my original code, there was no change in behavior. It still fails with a out of disk space exception.

I have no idea what else to try. Can you give any suggestions?

public boolean downloadToFile(URL url, File file){                                                                  
    boolean ok = false;                                                                                             

    try {                                                                                                           
        file.getParentFile().mkdirs();                                                                              

        BufferedInputStream  bis = new BufferedInputStream(url.openStream());                                       
        byte[]            buffer = new byte[2048];                                                                  
        FileOutputStream     fos = new FileOutputStream(file);                                                      
        BufferedOutputStream bos = new BufferedOutputStream( fos , buffer.length );                                 
        int size;                                                                                                   
        while ((size = bis.read(buffer, 0, buffer.length)) != -1) {                                                 
            bos.write(buffer, 0, size);                                                                             
        }                                                                                                           
        bos.flush();                                                                                                
        bos.close();                                                                                                
        bis.close();                                                                                                

        ok = true;                                                                                                  
    }catch(Exception e){                                                                                            
        e.printStackTrace();                                                                                        
    }                                                                                                               

    return ok;                                                                                                      
}
like image 667
Andreas Gohr Avatar asked Nov 13 '22 20:11

Andreas Gohr


1 Answers

Have a try with commons-io. Esspecially the Util Classes FileUtils and IOUtils

After changing our code to use commons-io all file operations went much smouther. Even with mapped network drives.

like image 77
powerMicha Avatar answered Dec 18 '22 05:12

powerMicha