GetDirectorySize invoked twice in InsertImage.aspx

  •  06-09-2011, 9:22 AM

    GetDirectorySize invoked twice in InsertImage.aspx

    I was researching slow performence issue when InsertImage.aspx is displayed and I have discovered that GetDirectory size is invoked twice.
     
    This method is invoked when displaying the amount of space used:
    <td>&nbsp; [[Used]]: <%= CuteEditor.Impl.FileStorage.FormatSize(fs.GetDirectorySize(fs.VirtualRoot)) %></td>
     
    And it's invoked a second time to calculate the percentage of space used:
    protected int GetUsedPercent() {
       
    int w = Convert.ToInt32(100*fs.GetDirectorySize(fs.VirtualRoot)/(secset.MaxImageFolderSize * 1024));
       if(w<1)
          
    w=1;
       if(w>100)
          
    w=100;
       return w;
    }
    This is obviously ineficient and causes the file repository to be scanned twice. I know some users have complained that the image galery is slow to open when there's a large number of files in the repository, I think InsertImage.aspx can be improved to make sure this method is invoked only once and therfore improve performance.
View Complete Thread