Browse Source

HPCC-22351 Force super file option when copying a super index

In this fix, ESP FileSpray.Copy is changed to force super file
option when copying a super index.

Revise based on review:
1. Use isEmptyString() to check srcDali;
2. Check the result from logical file lookup;
3. Make sure that 'foreign::' is in the file name when calling
the lookup for a foreign file.
4. Fix supercopy error in regress test

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 6 năm trước cách đây
mục cha
commit
80e12f4133
2 tập tin đã thay đổi với 29 bổ sung20 xóa
  1. 28 19
      esp/services/ws_fs/ws_fsService.cpp
  2. 1 1
      testing/regress/ecl/key/supercopy.xml

+ 28 - 19
esp/services/ws_fs/ws_fsService.cpp

@@ -2490,32 +2490,41 @@ bool CFileSprayEx::onCopy(IEspContext &context, IEspCopy &req, IEspCopyResponse
         StringBuffer fileMask;
         constructFileMask(destTitle.str(), fileMask);
 
+        Owned<IUserDescriptor> udesc=createUserDescriptor();
         const char* srcDali = req.getSourceDali();
-        bool supercopy = req.getSuperCopy();
-        if (supercopy)
+        const char* srcu = req.getSrcusername();
+        if (!isEmptyString(srcDali) && !isEmptyString(srcu))
+        {
+            udesc->set(srcu, req.getSrcpassword());
+        }
+        else
         {
             StringBuffer user, passwd;
             context.getUserID(user);
             context.getPassword(passwd);
-            StringBuffer u(user);
-            StringBuffer p(passwd);
-            Owned<INode> foreigndali;
-            if (srcDali)
-            {
-                SocketEndpoint ep(srcDali);
-                foreigndali.setown(createINode(ep));
-                const char* srcu = req.getSrcusername();
-                if(srcu && *srcu)
-                {
-                    u.clear().append(srcu);
-                    p.clear().append(req.getSrcpassword());
-                }
-            }
-            Owned<IUserDescriptor> udesc=createUserDescriptor();
-            udesc->set(u.str(),p.str());
-            if (!queryDistributedFileDirectory().isSuperFile(srcname,udesc,foreigndali))
+            udesc->set(user, passwd);
+        }
+
+        CDfsLogicalFileName logicalName;
+        logicalName.set(srcname);
+        if (!isEmptyString(srcDali))
+        {
+            SocketEndpoint ep(srcDali);
+            logicalName.setForeign(ep,false);
+        }
+
+        Owned<IDistributedFile> file = queryDistributedFileDirectory().lookup(logicalName, udesc);
+        if (!file)
+            throw MakeStringException(ECLWATCH_FILE_NOT_EXIST, "Failed to find file: %s", logicalName.get());
+
+        bool supercopy = req.getSuperCopy();
+        if (supercopy)
+        {
+            if (!file->querySuperFile())
                 supercopy = false;
         }
+        else if (file->querySuperFile() && isFileKey(file))
+            supercopy = true;
 
         Owned<IDFUWorkUnitFactory> factory = getDFUWorkUnitFactory();
         Owned<IDFUWorkUnit> wu = factory->createWorkUnit();

+ 1 - 1
testing/regress/ecl/key/supercopy.xml

@@ -13,7 +13,7 @@
  <Row><result>Copy superfile as superfle: Pass</result></Row>
 </Dataset>
 <Dataset name='Result 7'>
- <Row><result>Copy superindex as logical file: Fail</result></Row>
+ <Row><result>Copy superindex as logical file: Pass</result></Row>
 </Dataset>
 <Dataset name='Result 8'>
  <Row><result>Copy superindex as superfle: Pass</result></Row>