浏览代码

HPCC-23191 Remove @count from logical file Protect status

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith 5 年之前
父节点
当前提交
95864de389

+ 33 - 98
dali/base/dadfs.cpp

@@ -1129,8 +1129,6 @@ public:
     IFileDescriptor *createDescriptorFromMetaFile(const CDfsLogicalFileName &logicalname,IUserDescriptor *user);
 
     bool isProtectedFile(const CDfsLogicalFileName &logicalname, unsigned timeout) ;
-    unsigned queryProtectedCount(const CDfsLogicalFileName &logicalname, const char *owner);
-    bool getProtectedInfo(const CDfsLogicalFileName &logicalname, StringArray &names, UnsignedArray &counts);
     IDFProtectedIterator *lookupProtectedFiles(const char *owner=NULL,bool notsuper=false,bool superonly=false);
     IDFAttributesIterator* getLogicalFilesSorted(IUserDescriptor* udesc, DFUQResultField *sortOrder, const void *filterBuf, DFUQResultField *specialFilters,
             const void *specialFilterBuf, unsigned startOffset, unsigned maxNum, __int64 *cacheHint, unsigned *total, bool *allMatchingFilesReceived);
@@ -2035,14 +2033,9 @@ public:
             ForEach(*piter) {
                 const char *name = piter->get().queryProp("@name");
                 if (name&&*name) {
-                    unsigned count = piter->get().getPropInt("@count");
-                    if (count) {
-                        if (plist.length())
-                            plist.append(',');
-                        plist.append(name);
-                        if (count>1)
-                            plist.append(':').append(count);
-                    }
+                    if (plist.length())
+                        plist.append(',');
+                    plist.append(name);
                 }
             }
             if (plist.length()) {
@@ -2152,7 +2145,6 @@ class CDFProtectedIterator: implements IDFProtectedIterator, public CInterface
 {
     StringAttr owner;
     StringAttr fn;
-    unsigned count;
     bool issuper;
     Owned<IRemoteConnection> conn;
     Owned<IPropertyTreeIterator> fiter;
@@ -2168,7 +2160,6 @@ class CDFProtectedIterator: implements IDFProtectedIterator, public CInterface
         fn.set(t.queryProp("OrigName"));
         IPropertyTree &pt = piter->query();
         owner.set(pt.queryProp("@name"));
-        count = pt.getPropInt("@count");
     }
 
     void clear()
@@ -2185,7 +2176,6 @@ public:
     CDFProtectedIterator(const char *_owner,bool _notsuper,bool _superonly,unsigned _defaultTimeout)
         : owner(_owner)
     {
-        count = 0;
         issuper = false;
         notsuper=_notsuper;
         superonly=_superonly;
@@ -2282,11 +2272,6 @@ public:
         return owner;
     }
 
-    unsigned getCount()
-    {
-        return count;
-    }
-
     bool isSuper()
     {
         return issuper;
@@ -2619,38 +2604,33 @@ static bool setFileProtectTree(IPropertyTree &p,const char *owner, bool protect)
     bool ret = false;
     CDateTime dt;
     dt.setNow();
-    if (owner&&*owner) {
-        Owned<IPropertyTree> t = getNamedPropTree(&p,"Protect","@name",owner,false);
-        if (t) {
-            unsigned c = t->getPropInt("@count");
+    if (owner&&*owner)
+    {
+        Owned<IPropertyTree> t = getNamedPropTree(&p, "Protect", "@name", owner, false);
+        if (t)
+        {
             if (protect)
-                c++;
-            else {
-                if (c>=1) {
-                    p.removeTree(t);
-                    c = 0;
-                }
-                else
-                    c--;
-            }
-            if (c) {
-                t->setPropInt("@count",c);
+            {
                 StringBuffer str;
-                t->setProp("@modified",dt.getString(str).str());
+                t->setProp("@modified", dt.getString(str).str());
             }
+            else
+                p.removeTree(t);
         }
-        else if (protect) {
-            t.setown(addNamedPropTree(&p,"Protect","@name",owner));
-            t->setPropInt("@count",1);
+        else if (protect)
+        {
+            t.setown(addNamedPropTree(&p, "Protect", "@name", owner));
             StringBuffer str;
             t->setProp("@modified",dt.getString(str).str());
         }
         ret = true;
     }
-    else if (!protect) {
+    else if (!protect)
+    {
         unsigned n=0;
         IPropertyTree *pt;
-        while ((pt=p.queryPropTree("Protect[1]"))!=NULL) {
+        while ((pt=p.queryPropTree("Protect[1]"))!=NULL)
+        {
             p.removeTree(pt);
             n++;
         }
@@ -2664,18 +2644,18 @@ static bool checkProtectAttr(const char *logicalname,IPropertyTree *froot,String
 {
     Owned<IPropertyTreeIterator> wpiter = froot->getElements("Attr/Protect");
     bool prot = false;
-    ForEach(*wpiter) {
+    ForEach(*wpiter)
+    {
         IPropertyTree &t = wpiter->query();
-        if (t.getPropInt("@count")) {
-            const char *wpname = t.queryProp("@name");
-            if (!wpname||!*wpname)
-                wpname = "<Unknown>";
-            if (prot)
-                reason.appendf(", %s",wpname);
-            else {
-                reason.appendf("file %s protected by %s",logicalname,wpname);
-                prot = true;
-            }
+        const char *wpname = t.queryProp("@name");
+        if (!wpname||!*wpname)
+            wpname = "<Unknown>";
+        if (prot)
+            reason.appendf(", %s", wpname);
+        else
+        {
+            reason.appendf("file %s protected by %s", logicalname, wpname);
+            prot = true;
         }
     }
     return prot;
@@ -5199,7 +5179,7 @@ protected:
         if (pos==0)
         {
             Owned<IPropertyTree> superAttrs = createPTreeFromIPT(&file->queryAttributes());
-            superAttrs->removeProp("Protect"); // do not automatically inherit protected status
+            while (superAttrs->removeProp("Protect")); // do not automatically inherit protected status
             resetFileAttr(superAttrs.getClear());
         }
         root->addPropTree("SubFile",sub);
@@ -5229,7 +5209,7 @@ protected:
             if (subfiles.ordinality())
             {
                 Owned<IPropertyTree> superAttrs = createPTreeFromIPT(&subfiles.item(0).queryAttributes());
-                superAttrs->removeProp("Protect"); // do not automatically inherit protected status
+                while (superAttrs->removeProp("Protect")); // do not automatically inherit protected status
                 resetFileAttr(superAttrs.getClear());
             }
             else
@@ -12457,52 +12437,7 @@ bool CDistributedFileDirectory::isProtectedFile(const CDfsLogicalFileName &logic
     CFileAttrLock attrLock;
     if (!attrLock.init(logicalName, RTM_LOCK_READ, NULL, timeout?timeout:INFINITE, "CDistributedFileDirectory::isProtectedFile"))
         return false; // timeout will raise exception
-    Owned<IPropertyTreeIterator> wpiter = attrLock.queryRoot()->getElements("Protect");
-    bool prot = false;
-    ForEach(*wpiter) {
-        IPropertyTree &t = wpiter->query();
-        if (t.getPropInt("@count")) {
-            prot = true;
-            break;
-        }
-    }
-    // timeout retry TBD
-    return prot;
-}
-
-unsigned CDistributedFileDirectory::queryProtectedCount(const CDfsLogicalFileName &logicalName, const char *owner)
-{
-    CFileAttrLock attrLock;
-    if (!attrLock.init(logicalName, RTM_LOCK_READ, NULL, defaultTimeout, "CDistributedFileDirectory::queryProtectedCount"))
-        return 0; // timeout will raise exception
-    Owned<IPropertyTreeIterator> wpiter = attrLock.queryRoot()->getElements("Protect");
-    unsigned count = 0;
-    ForEach(*wpiter) {
-        IPropertyTree &t = wpiter->query();
-        const char *name = t.queryProp("@name");
-        if (!owner||!*owner||(name&&(strcmp(owner,name)==0)))
-            count += t.getPropInt("@count");
-    }
-    return count;
-}
-
-bool CDistributedFileDirectory::getProtectedInfo(const CDfsLogicalFileName &logicalName, StringArray &names, UnsignedArray &counts)
-{
-    CFileAttrLock attrLock;
-    if (!attrLock.init(logicalName, RTM_LOCK_READ, NULL, defaultTimeout, "CDistributedFileDirectory::getProtectedInfo"))
-        return false; // timeout will raise exception
-    Owned<IPropertyTreeIterator> wpiter = attrLock.queryRoot()->getElements("Protect");
-    bool prot = false;
-    ForEach(*wpiter) {
-        IPropertyTree &t = wpiter->query();
-        const char *name = t.queryProp("@name");
-        names.append(name?name:"<Unknown>");
-        unsigned c = t.getPropInt("@count");
-        if (c)
-            prot = true;
-        counts.append(c);
-    }
-    return prot;
+    return attrLock.queryRoot()->hasProp("Protect");
 }
 
 IDFProtectedIterator *CDistributedFileDirectory::lookupProtectedFiles(const char *owner,bool notsuper,bool superonly)

+ 0 - 7
dali/base/dadfs.hpp

@@ -81,7 +81,6 @@ interface IDFProtectedIterator: public IInterface
     virtual bool isValid() = 0;
     virtual const char *queryFilename() = 0;
     virtual const char *queryOwner() = 0;
-    virtual unsigned getCount() = 0;
     virtual bool isSuper() = 0;
 };
 
@@ -680,12 +679,6 @@ interface IDistributedFileDirectory: extends IInterface
                                       unsigned timeout=0                // 0 = return state immediately, >0 waits until false or timed-out
                                      ) = 0;
 
-    virtual unsigned queryProtectedCount(const CDfsLogicalFileName &logicalname,
-                                  const char *callerid=NULL) = 0;                   // if NULL  then sums all
-
-    virtual bool getProtectedInfo (const CDfsLogicalFileName &logicalname,
-                                           StringArray &names, UnsignedArray &counts) = 0;
-
     virtual IDFProtectedIterator *lookupProtectedFiles(const char *owner=NULL,bool notsuper=false,bool superonly=false)=0; // if owner = NULL then all
     virtual IDFAttributesIterator* getLogicalFilesSorted(IUserDescriptor* udesc, DFUQResultField *sortOrder, const void* filters, DFUQResultField *localFilters,
             const void *specialFilterBuf, unsigned startOffset, unsigned maxNum, __int64 *cacheHint, unsigned *total, bool *allMatchingFilesReceived) = 0;

+ 1 - 1
dali/daliadmin/daliadmin.cpp

@@ -1180,7 +1180,7 @@ static void listprotect(const char *filename, const char *callerid)
     Owned<IDFProtectedIterator> piter = queryDistributedFileDirectory().lookupProtectedFiles((strcmp(callerid,"*")==0)?NULL:callerid); 
     ForEach(*piter) {
         if (WildMatch(piter->queryFilename(),filename))
-            OUTLOG("%s,%s,%s,%u",piter->isSuper()?"SuperFile":"File",piter->queryFilename(),piter->queryOwner(),piter->getCount());
+            OUTLOG("%s,%s,%s", piter->isSuper()?"SuperFile":"File", piter->queryFilename(), piter->queryOwner());
     }
 }
 

+ 3 - 3
esp/scm/ws_dfu.ecm

@@ -158,7 +158,7 @@ ESPStruct [nil_remove] DFUFilePartsOnCluster
 ESPStruct [nil_remove] DFUFileProtect
 {
     string Owner;
-    int Count;
+    [depr_ver("1.54")] int Count;
     string Modified;
 };
 
@@ -986,8 +986,8 @@ ESPresponse [exceptions_inline, nil_remove] DFUFilePublishResponse
 //  ===========================================================================
 ESPservice [
     auth_feature("DEFERRED"),
-    version("1.53"),
-    default_client_version("1.53"),
+    version("1.54"),
+    default_client_version("1.54"),
     noforms,
     exceptions_inline("./smc_xslt/exceptions.xslt")] WsDfu
 {

+ 2 - 2
esp/services/ws_dfu/ws_dfuService.cpp

@@ -2096,13 +2096,13 @@ void CWsDfuEx::doGetFileDetails(IEspContext &context, IUserDescriptor *udesc, co
             IPropertyTree &tree = itr->query();
             const char *owner = tree.queryProp("@name");
             const char *modified = tree.queryProp("@modified");
-            int count = tree.getPropInt("@count", 0);
             Owned<IEspDFUFileProtect> protect= createDFUFileProtect();
             if(owner && *owner)
                 protect->setOwner(owner);
             if(modified && *modified)
                 protect->setModified(modified);
-            protect->setCount(count);
+            if (version < 1.54)
+                protect->setCount(1);
             protectList.append(*protect.getLink());
         }
         FileDetails.setProtectList(protectList);

+ 3 - 6
plugins/fileservices/fileservices.cpp

@@ -2582,12 +2582,9 @@ FILESERVICES_API char * FILESERVICES_CALL fsfGetLogicalFileAttribute(ICodeContex
             ForEach(*piter) {
                 const char *name = piter->get().queryProp("@name");
                 if (name&&*name) {
-                    unsigned count = piter->get().getPropInt("@count");
-                    if (count) {
-                        if (ret.length())
-                            ret.append(',');
-                        ret.append(name);
-                    }
+                    if (ret.length())
+                        ret.append(',');
+                    ret.append(name);
                 }
             }
         }