diff options
Diffstat (limited to 'Duplicati/Library/Backend/SharePoint/SharePointBackend.cs')
-rw-r--r-- | Duplicati/Library/Backend/SharePoint/SharePointBackend.cs | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs b/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs index 4793cf9a1..8e837e39f 100644 --- a/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs +++ b/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs @@ -393,8 +393,8 @@ namespace Duplicati.Library.Backend testContextForWeb(ctx, true); } - public List<IFileEntry> List() { return doList(false); } - private List<IFileEntry> doList(bool useNewContext) + public IEnumerable<IFileEntry> List() { return doList(false); } + private IEnumerable<IFileEntry> doList(bool useNewContext) { SP.ClientContext ctx = getSpClientContext(useNewContext); try @@ -407,20 +407,7 @@ namespace Duplicati.Library.Backend if (!remoteFolder.Exists) throw new Interface.FolderMissingException(Strings.SharePoint.MissingElementError(m_serverRelPath, m_spWebUrl)); - List<IFileEntry> files = new List<IFileEntry>(remoteFolder.Folders.Count + remoteFolder.Files.Count); - foreach (var f in remoteFolder.Folders.Where(ff => ff.Exists)) - { - FileEntry fe = new FileEntry(f.Name, -1, f.TimeLastModified, f.TimeLastModified); // f.TimeCreated - fe.IsFolder = true; - files.Add(fe); - } - foreach (var f in remoteFolder.Files.Where(ff => ff.Exists)) - { - FileEntry fe = new FileEntry(f.Name, f.Length, f.TimeLastModified, f.TimeLastModified); // f.TimeCreated - fe.IsFolder = false; - files.Add(fe); - } - return files; + return doListWithoutExceptionCatch(remoteFolder); } catch (ServerException) { throw; /* rethrow if Server answered */ } catch (Interface.FileMissingException) { throw; } @@ -429,6 +416,22 @@ namespace Duplicati.Library.Backend finally { } } + private IEnumerable<IFileEntry> doListWithoutExceptionCatch(SP.Folder remoteFolder) + { + foreach (var f in remoteFolder.Folders.Where(ff => ff.Exists)) + { + FileEntry fe = new FileEntry(f.Name, -1, f.TimeLastModified, f.TimeLastModified); // f.TimeCreated + fe.IsFolder = true; + yield return fe; + } + foreach (var f in remoteFolder.Files.Where(ff => ff.Exists)) + { + FileEntry fe = new FileEntry(f.Name, f.Length, f.TimeLastModified, f.TimeLastModified); // f.TimeCreated + fe.IsFolder = false; + yield return fe; + } + } + public void Get(string remotename, string filename) { using (System.IO.FileStream fs = System.IO.File.Create(filename)) |