Browse Source

HPCC-18200 Sort files by compressed/uncompressed in DFUQuery

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 7 years ago
parent
commit
880c986d78
3 changed files with 21 additions and 5 deletions
  1. 15 1
      dali/base/dadfs.cpp
  2. 2 1
      dali/base/dadfs.hpp
  3. 4 3
      esp/services/ws_dfu/ws_dfuService.cpp

+ 15 - 1
dali/base/dadfs.cpp

@@ -12189,7 +12189,7 @@ IDFProtectedIterator *CDistributedFileDirectory::lookupProtectedFiles(const char
 
 const char* DFUQResultFieldNames[] = { "@name", "@description", "@group", "@kind", "@modified", "@job", "@owner",
     "@DFUSFrecordCount", "@recordCount", "@recordSize", "@DFUSFsize", "@size", "@workunit", "@DFUSFcluster", "@numsubfiles",
-    "@accessed", "@numparts", "@compressedSize", "@directory", "@partmask", "@superowners", "@persistent", "@protect" };
+    "@accessed", "@numparts", "@compressedSize", "@directory", "@partmask", "@superowners", "@persistent", "@protect", "@isCompressedFile" };
 
 extern da_decl const char* getDFUQResultFieldName(DFUQResultField feild)
 {
@@ -12252,6 +12252,19 @@ IPropertyTreeIterator *deserializeFileAttrIterator(MemoryBuffer& mb, unsigned nu
             return;
         }
 
+        void setIsCompressed(IPropertyTree* file)
+        {
+            if (isCompressed(*file))
+            {
+                file->setPropBool(getDFUQResultFieldName(DFUQRFiscompressed), true);
+                return;
+            }
+
+            const char * kind = file->queryProp(getDFUQResultFieldName(DFUQRFkind));
+            if (!isEmptyString(kind) && strieq(kind, "key"))
+                file->setPropBool(getDFUQResultFieldName(DFUQRFiscompressed), true);
+        }
+
         IPropertyTree *deserializeFileAttr(MemoryBuffer &mb, StringArray& nodeGroupFilter)
         {
             IPropertyTree *attr = getEmptyAttr();
@@ -12289,6 +12302,7 @@ IPropertyTreeIterator *deserializeFileAttrIterator(MemoryBuffer& mb, unsigned nu
             }
             attr->setPropInt64(getDFUQResultFieldName(DFUQRFsize), attr->getPropInt64(getDFUQResultFieldName(DFUQRForigsize), -1));//Sort the files with empty size to front
             setRecordCount(attr);
+            setIsCompressed(attr);
             return attr;
         }
 

+ 2 - 1
dali/base/dadfs.hpp

@@ -270,7 +270,8 @@ enum DFUQResultField
     DFUQRFsuperowners = 20,
     DFUQRFpersistent = 21,
     DFUQRFprotect = 22,
-    DFUQRFterm = 23,
+    DFUQRFiscompressed = 23,
+    DFUQRFterm = 24,
     DFUQRFreverse = 256,
     DFUQRFnocase = 512,
     DFUQRFnumeric = 1024

+ 4 - 3
esp/services/ws_dfu/ws_dfuService.cpp

@@ -3214,6 +3214,8 @@ void CWsDfuEx::setDFUQuerySortOrder(IEspDFUQueryRequest& req, StringBuffer& sort
     const char* sortByPtr = sortBy.str();
     if (strieq(sortByPtr, "FileSize"))
         sortOrder[0] = (DFUQResultField) (DFUQRFsize | DFUQRFnumeric);
+    else if (strieq(sortByPtr, "IsCompressed"))
+        sortOrder[0] = (DFUQResultField) (DFUQRFiscompressed | DFUQRFnumeric);
     else if (strieq(sortByPtr, "CompressedSize"))
         sortOrder[0] = (DFUQResultField) (DFUQRFcompressedsize | DFUQRFnumeric);
     else if (strieq(sortByPtr, "Parts"))
@@ -3337,10 +3339,9 @@ bool CWsDfuEx::addToLogicalFileList(IPropertyTree& file, const char* nodeGroup,
                     lFile->setIsKeyFile(isKeyFile);
             }
         }
-        bool isFileCompressed = false;
-        if (isKeyFile || isCompressed(file))
+        bool isFileCompressed = file.getPropBool(getDFUQResultFieldName(DFUQRFiscompressed));
+        if (isFileCompressed)
         {
-            isFileCompressed = true;
             if (version >= 1.22)
             {
                 if (file.hasProp(getDFUQResultFieldName(DFUQRFcompressedsize)))