From 20c3dcd8e5f0bb5f1cbfba77912ff3444de3a3a2 Mon Sep 17 00:00:00 2001 From: "kenneth@hexad.dk" Date: Mon, 14 May 2012 18:45:48 +0000 Subject: [PATCH] Update issue #617 Status: Fixed The googledocs backend now parses hierarchical folders in any depth, except if a folder has multiple direct parents. git-svn-id: https://duplicati.googlecode.com/svn/trunk@1272 59da171f-624f-0410-aa54-27559c288bec --- .../Library/Backend/GoogleDocs/GoogleDocs.cs | 26 ++++++++++++++++--- .../GoogleDocs/Strings/GoogleDocs.Designer.cs | 11 +++++++- .../GoogleDocs/Strings/GoogleDocs.resx | 7 +++-- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Duplicati/Library/Backend/GoogleDocs/GoogleDocs.cs b/Duplicati/Library/Backend/GoogleDocs/GoogleDocs.cs index f1cb5162d..ea58faf21 100644 --- a/Duplicati/Library/Backend/GoogleDocs/GoogleDocs.cs +++ b/Duplicati/Library/Backend/GoogleDocs/GoogleDocs.cs @@ -162,11 +162,29 @@ namespace Duplicati.Library.Backend foreach (Google.Documents.Document d in parentlookup.Values) { - string[] p = new string[d.ParentFolders.Count + 1]; - for (int i = 0; i < p.Length - 1; i++) - p[i] = parentlookup[d.ParentFolders[i]].Title; + List parents = new List(); + Google.Documents.Document cur = d; + while (cur.ParentFolders.Count == 1) + { + parents.Add(cur); + cur = parentlookup[cur.ParentFolders[0]]; + } + parents.Add(cur); + + if (cur.ParentFolders.Count != 0) + { + string[] pids = new string[cur.ParentFolders.Count]; + for(int i = 0; i < pids.Length; i++) + pids[i] = parentlookup[cur.ParentFolders[i]].Title; + + throw new Exception(string.Format(Strings.GoogleDocs.FolderHasMultipleOwnersError, cur.Title, string.Join(", ", pids))); + } + + parents.Reverse(); + string[] p = new string[parents.Count]; + for (int i = 0; i < p.Length; i++) + p[i] = parents[i].Title; - p[p.Length - 1] = d.Title; string key = string.Join("/", p); if (dict.ContainsKey(key)) throw new Exception(string.Format(Strings.GoogleDocs.DuplicateFoldernameFoundError, key)); diff --git a/Duplicati/Library/Backend/GoogleDocs/Strings/GoogleDocs.Designer.cs b/Duplicati/Library/Backend/GoogleDocs/Strings/GoogleDocs.Designer.cs index d52e7d0bc..12a3312b8 100644 --- a/Duplicati/Library/Backend/GoogleDocs/Strings/GoogleDocs.Designer.cs +++ b/Duplicati/Library/Backend/GoogleDocs/Strings/GoogleDocs.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.239 +// Runtime Version:4.0.30319.269 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -204,6 +204,15 @@ namespace Duplicati.Library.Backend.Strings { } } + /// + /// Looks up a localized string similar to The folder {0} is owned by multiple parents: {1}, this is not supported. + /// + internal static string FolderHasMultipleOwnersError { + get { + return ResourceManager.GetString("FolderHasMultipleOwnersError", resourceCulture); + } + } + /// /// Looks up a localized string similar to The nonce returned was not recognized: {0}. /// diff --git a/Duplicati/Library/Backend/GoogleDocs/Strings/GoogleDocs.resx b/Duplicati/Library/Backend/GoogleDocs/Strings/GoogleDocs.resx index d458928f0..1ea732d9d 100644 --- a/Duplicati/Library/Backend/GoogleDocs/Strings/GoogleDocs.resx +++ b/Duplicati/Library/Backend/GoogleDocs/Strings/GoogleDocs.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 The account access has been blocked by Google, please visit this URL and unlock it: {0} @@ -165,6 +165,9 @@ The requested file is read-only: {0} + + The folder {0} is owned by multiple parents: {1}, this is not supported + The nonce returned was not recognized: {0}