Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gill <tyler.gill@byu.net>2017-09-26 08:17:45 +0300
committerTyler Gill <tyler.gill@byu.net>2017-09-26 08:17:45 +0300
commit38883285eee5598e37d56e6ddc417fad7d872ed3 (patch)
treed542798f8594aca02d954128f0fe63f32f28b512 /Duplicati/Library/Backend/Mega/MegaBackend.cs
parent6c921ab3ec878a99262150b80b7f29713700c11e (diff)
Change IBackend.List() to return IEnumerable instead of List
By changing to IEnumerable, it is possible to iterate only a portion of the list, which is useful when not all entries are needed (e.g., when testing a connection). All existing backends have been updated, and any which were able to be changed to yield return results in a straightforward way now do. Many backends had a try/catch in the List() method. Due to the fact that yield returns can't be placed within a try/catch block, these have been refactored to either scope the try/catch to the parts that (should) be the only places throwing exceptions, so that exceptions are still caught and handled. Note that lazy evaluation may cause some changes in behavior - exceptions that were previously thrown at the point of invokation of List() may now be thrown while it is being enumerated. I believe this will not be problematic though, as the only well-known exception seems to be FolderMissingException, which should be thrown by Test(), but TestList() attempts to enumerate the list to force this exception. Any places that require the legacy behavior can get it by simply converting the lazy enumerable to a List()
Diffstat (limited to 'Duplicati/Library/Backend/Mega/MegaBackend.cs')
-rw-r--r--Duplicati/Library/Backend/Mega/MegaBackend.cs9
1 files changed, 4 insertions, 5 deletions
diff --git a/Duplicati/Library/Backend/Mega/MegaBackend.cs b/Duplicati/Library/Backend/Mega/MegaBackend.cs
index 732f0f040..e9261717f 100644
--- a/Duplicati/Library/Backend/Mega/MegaBackend.cs
+++ b/Duplicati/Library/Backend/Mega/MegaBackend.cs
@@ -170,16 +170,15 @@ namespace Duplicati.Library.Backend.Mega
#region IBackend implementation
- public List<IFileEntry> List()
+ public IEnumerable<IFileEntry> List()
{
if (m_filecache == null)
ResetFileCache();
- return (
+ return
from n in m_filecache.Values
let item = n.OrderByDescending(x => x.ModificationDate).First()
- select (IFileEntry)new FileEntry(item.Name, item.Size, item.ModificationDate ?? new DateTime(0), item.ModificationDate ?? new DateTime(0))
- ).ToList();
+ select new FileEntry(item.Name, item.Size, item.ModificationDate ?? new DateTime(0), item.ModificationDate ?? new DateTime(0));
}
public void Put(string remotename, string filename)
@@ -218,7 +217,7 @@ namespace Duplicati.Library.Backend.Mega
public void Test()
{
- List();
+ this.TestList();
}
public void CreateFolder()