22# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
33# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
44#
5- # (c) 2024 . (c) 2024 .
5+ # (c) 2025 . (c) 2025 .
66# Government of Canada Gouvernement du Canada
77# National Research Council Conseil national de recherches
88# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
@@ -811,7 +811,7 @@ def get_children(self, client, sort, order, limit=None):
811811 """ Gets an iterator over the nodes held to by a ContainerNode"""
812812 # IF THE CALLER KNOWS THEY DON'T NEED THE CHILDREN THEY
813813 # CAN SET LIMIT=0 IN THE CALL Also, if the number of nodes
814- # on the firt call was less than 500, we likely got them
814+ # on the first call was less than 500, we likely got them
815815 # all during the init
816816 if not self .isdir ():
817817 return
@@ -1890,7 +1890,7 @@ def copy(self, source, destination, send_md5=False, disposition=False,
18901890 # purposes:
18911891 # 1. Check if source is identical to destination and
18921892 # avoid sending the bytes again.
1893- # 2. send info to the service so it can recover in case
1893+ # 2. send info to the service so that it can recover in case
18941894 # the bytes got corrupted on the way
18951895 src_md5 = md5_cache .MD5Cache .compute_md5 (source )
18961896 if src_md5 == dest_node_md5 :
@@ -2186,8 +2186,7 @@ def get_node_url(self, uri, method='GET', view=None, limit=None,
21862186 def link (self , src_uri , link_uri ):
21872187 """Make link_uri point to src_uri.
21882188
2189- :param src_uri: the existing resource, either a vospace uri or a http
2190- url
2189+ :param src_uri: the existing resource to link to
21912190 :type src_uri: unicode
21922191 :param link_uri: the vospace node to create that will be a link to
21932192 src_uri
@@ -2197,7 +2196,8 @@ def link(self, src_uri, link_uri):
21972196 HttpException exceptions declared in the cadcutils.exceptions module
21982197 """
21992198 link_uri = self .fix_uri (link_uri )
2200- src_uri = self .fix_uri (src_uri )
2199+ if "://" not in src_uri :
2200+ src_uri = self .fix_uri (src_uri )
22012201
22022202 # if the link_uri points at an existing directory then we try and
22032203 # make a link into that directory
@@ -2723,24 +2723,23 @@ def get_info_list(self, uri):
27232723
27242724 def listdir (self , uri , force = False ):
27252725 """
2726- Walk through the directory structure a la os.walk.
2727- Setting force=True will make sure no cached results are used.
2726+ Return a list with the content of the directory
27282727 Follows LinksNodes to their destination location.
2728+ Note: this method returns a list of children names. For larger
2729+ directories, use get_children_info() to iterate through it and
2730+ avoid loading the entire content into memory.
27292731
27302732 :param force: don't use cached values, retrieve from service.
27312733 :param uri: The ContainerNode to get a listing of.
27322734 :rtype [unicode]
27332735 """
2734- names = []
27352736 logger .debug (str (uri ))
2736- node = self .get_node (uri , limit = None , force = force )
2737+ node = self .get_node (uri , limit = 0 , force = force )
27372738 while node .type == "vos:LinkNode" :
27382739 uri = node .target
27392740 # logger.debug(uri)
2740- node = self .get_node (uri , limit = None , force = force )
2741- for thisNode in node .node_list :
2742- names .append (thisNode .name )
2743- return names
2741+ node = self .get_node (uri , limit = 0 , force = force )
2742+ return [i .name for i in self .get_children_info (node .uri , force = force )]
27442743
27452744 def _node_type (self , uri ):
27462745 """
0 commit comments