Browse Source

HPCC-19168 getDir must return null iterator on invalid path/file

To preserve legacy semantics, a directoryIterator returns a empty
iterator on an non-existent or invalid file. For both
whether local or remote. HPCC-18725 changed that, causing a call
on a non-existent to return an error.

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith 7 years ago
parent
commit
014132f860
1 changed files with 5 additions and 7 deletions
  1. 5 7
      common/remote/sockfile.cpp

+ 5 - 7
common/remote/sockfile.cpp

@@ -5315,15 +5315,13 @@ public:
             StringBuffer fullFilename(name);
             addPathSepChar(fullFilename).append(mask);
             Owned<IFile> iFile = createIFile(fullFilename);
+
+            // NB: This must preserve same serialization format as CRemoteDirectoryIterator::serialize produces for <=1 file.
+            reply.append((unsigned)RFEnoerror);
             if (!iFile->exists())
-            {
-                reply.append((unsigned)RFSERR_GetDirFailed);
-                return false;
-            }
+                reply.append((byte)0);
             else
             {
-                reply.append((unsigned)RFEnoerror);
-                // NB: This must preserve same serialization format as CRemoteDirectoryIterator::serialize produces for 1 file.
                 byte b=1;
                 reply.append(b);
                 bool isDir = foundYes == iFile->isDirectory();
@@ -5335,8 +5333,8 @@ public:
                 reply.append(iFile->queryFilename());
                 b = 0;
                 reply.append(b);
-                return true;
             }
+            return true;
         }
         else
         {