better way to find the folder

This commit is contained in:
Andrew Dumaresq
2015-01-11 11:57:14 -05:00
parent ee8406e026
commit 20e1283627

View File

@@ -28,6 +28,19 @@ class PutIO(DownloaderBase):
return super(PutIO, self).__init__()
# This is a recusive function to check for the folders
def recursionFolder(self, client, folder, tfolder):
files = client.File.list(folder)
for f in files:
if f.name == tfolder and f.content_type == "application/x-directory":
return f.id
elif f.content_type == "application/x-directory":
result = self.recursionFolder(client, f.id, tfolder)
if result != 0:
return result
return 0
# This will check the root for the folder, and kick of recusively checking sub folder
def convertFolder(self, client, folder):
if folder == 0:
return 0
@@ -36,6 +49,10 @@ class PutIO(DownloaderBase):
for f in files:
if f.name == folder and f.content_type == "application/x-directory":
return f.id
elif f.content_type == "application/x-directory":
result = self.recursionFolder(client, f.id, folder)
if result != 0:
return result
#If we get through the whole list and don't get a match we will use the root
return 0