1
Vote

bad cache workaround

description

I noticed that when a different view re-created a new directory structure, ElFinder.net appeared to try to use existing hash information, so would fail during the initial changeover, but succeed thereafter.

I added this retry to start over when the folder wasn't found, to resolve my issue. Perhaps there is some other way of clearing for restarting within my Connector code, but I couldn't see it. Please let me know if there is a more elegant way of clearing the system when re-creating the driver and roots.

JsonResult IDriver.Init(string target)
    {
        FullPath fullPath;
    retry:
        if (string.IsNullOrEmpty(target))
        {

            Root root = _roots.FirstOrDefault(r => r.StartPath != null);
            if (root == null)
                root = _roots.First();
            fullPath = new FullPath(root, root.StartPath??root.Directory);
        }
        else
        {
            fullPath = ParsePath(target);
            if (fullPath.Directory == null)  // bad or old tree
            {
                target = null;
                goto retry;

            }

        }
....

comments

EvgenyNoskov wrote Sep 25, 2014 at 2:32 PM

Hi, and thanks for feedback.

I really don't like 'goto-style' :)
FullPath fullPath = null;
if(!string.IsNullOrEmpty(target))
{
   fullPath = ParsePath(target);
   if (fullPath.Directory == null)
       target = null;
}

if (string.IsNullOrEmpty(target))
{
   Root root = _roots.FirstOrDefault(r => r.StartPath != null);
   if (root == null)
       root = _roots.First();
   fullPath = new FullPath(root, root.StartPath??root.Directory);
}
I will commit this change a bit later, or you do can do it by yourself.