Ejemplo n.º 1
0
    def getObjectList(self,bucket_name,prefix,marker,max_keys,terse=0):
         
        path = self._getBucketPath(bucket_name)
       
        if not os.path.isdir(path):
            raise web.HTTPError(404)
        
        #FIXME
        object_names = []
        dirs = os.listdir(path)
        for dir in dirs:
            new_path = os.path.join(path,dir)
            if os.path.isdir(new_path):
                self._findObjects(new_path, object_names)
                
        skip = len(path) + 1
        for i in range(self._BUCKET_DEPTH):
            skip += 2 * (i + 1) + 1 
        object_names = [n[skip:] for n in object_names]
        object_names.sort()
        
        contents = []

        #FIXME move filter on file scan
        start_pos = 0
        if marker:
            start_pos = bisect.bisect_right(object_names, marker, start_pos)
        if prefix:
            start_pos = bisect.bisect_left(object_names, prefix, start_pos)

        truncated = False
        for object_name in object_names[start_pos:]:
            if not object_name.startswith(prefix):
                break
            if len(contents) >= max_keys:
                truncated = True
                break
            
            obj = ObjectProperties(bucket_name=bucket_name,object_name=object_name)
            
            if not terse:
                obj =  self.getObjectProperties(bucket_name,object_name)
                
            contents.append(obj)
            marker = object_name
        
        res = ObjectQueryResult(bucket_name, prefix,marker,max_keys,truncated)
        res.setObjectList(contents)
        return res
Ejemplo n.º 2
0
    def getObjectList(self,bucket_name, user, session, prefix, marker, max_keys,terse=0):
        context = ''
        gid=''
        
        res = ObjectQueryResult(bucket_name, prefix, marker,max_keys, False)
        path = "/"+prefix
        if not path.endswith("/"):
            path +="/"

        idObject = self.meta.lookup(bucket_name, path)
        
        if not idObject:
            raise RestFSError(errCode.err['ObjectNotFound']['code'],\
                          errCode.err['ObjectNotFound']['message'],\
                          errCode.err['ObjectNotFound']['http'])
            
         
        # We want all information 
        myList = self.meta.getObjectList(idObject,user.id, gid, context,meta=True)
        res.setObjectList(myList)
        return res