Changeset 509

Show
Ignore:
Timestamp:
2007-07-11 01:45:02 (1 year ago)
Author:
MaierMan
Message:

fixing #253: diskSpaceAvailable fails Win/Minefiled, Linux/All

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/common/internalFunctions.js

    r488 r509  
    260260        }, 
    261261        /** 
     262         * Gets the disk-space available for a nsILocalFile. 
     263         * Here, because diskSpaceAvailable requires valid path and/or path to be a directory 
     264         * @param file Valid nsILocalFile 
     265         * @return the diskspace available to the caller 
     266         * @author Nils 
     267         */ 
     268        getFreeDisk: function(file) { 
     269                while (file) { 
     270                        if (file.exists() && file.isDirectory()) { 
     271                                return file.diskSpaceAvailable; 
     272                        } 
     273                        file = file.parent; 
     274                } 
     275                return 0; 
     276        }, 
     277        /** 
    262278         * Play a sound file (if prefs allow to do so) 
    263279         * @param name Name of the sound (correpsonding to the pref name and the file name of desired sound) 
  • trunk/chrome/content/dta/manager.js

    r500 r509  
    19631963                                                if (tmp) { 
    19641964                                                        vtmp = Utils.validateDir(tmp); 
    1965                                                         if (!vtmp && vtmp.diskSpaceAvailable < tsd) { 
     1965                                                        if (!vtmp && Utils.getFreeDisk(vtmp) < tsd) { 
    19661966                                                                d.fail(_("ndsa"), _("spacetemp"), _("freespace")); 
    19671967                                                                return; 
     
    19721972                                                        throw new Error("invalid destination folder"); 
    19731973                                                } 
    1974                                                 var nsd = realDest.diskSpaceAvailable
     1974                                                var nsd = Utils.getFreeDisk(realDest)
    19751975                                                // Same save path or same disk (we assume that tmp.avail == dst.avail means same disk) 
    19761976                                                // simply moving should succeed 
    1977                                                 if (d.compression && (!tmp || vtmp.diskSpaceAvailable == nsd)) { 
     1977                                                if (d.compression && (!tmp || Utils.getFreeDisk(vtmp) == nsd)) { 
    19781978                                                        // we cannot know how much space we will consume after decompressing. 
    19791979                                                        // so we assume factor 1.0 for the compressed and factor 1.5 for the decompressed file. 
     
    19811981                                                } 
    19821982                                                if (nsd < tsd) { 
     1983                                                        Debug.dump("nsd", nsd); 
     1984                                                        Debug.dump("tsd", tsd); 
    19831985                                                        d.fail(_("ndsa"), _("spacedir"), _("freespace")); 
    19841986                                                        return;