cweidenkeller / csharp-swift Goto Github PK
View Code? Open in Web Editor NEWA light Rest Wrapper for OpenStack Swift
License: MIT License
A light Rest Wrapper for OpenStack Swift
License: MIT License
Hi,
Please see https://github.com/rackspace/csharp-cloudfiles/issues/51, the last comment by 'horacioj'
The exception does happens in fact in this library (which I wish I could be able to understand and fix myself, but unfortunately I'm not that smart...)
var query = new Dictionary<ObjectQuery, string>();
query.Add(ObjectQuery.Prefix, "folder1/");
query.Add(ObjectQuery.Delimiter, "/");
list = container.GetObjectList(query);
Exception:
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at OpenStack.Swift.SwiftClient.GetContainer(String url, String token, String container, Dictionary`2 headers, Dictionary`2 query, Boolean full_listing) in C:\Cloudfiles\rackspace-csharp-cloudfiles\cweidenkeller-csharp-swift-eedd837\src\OpenStack.Swift\Client.cs:line 312
at Cloudfiles.CF_Container.GetObjectList(Boolean full_listing, Dictionary`2 query) in C:\Cloudfiles\rackspace-csharp-cloudfiles\Rackspace.Cloudfiles\CF_Container.cs:line 632
at Cloudfiles.CF_Container.GetObjectList(Dictionary`2 query) in C:\Cloudfiles\rackspace-csharp-cloudfiles\Rackspace.Cloudfiles\CF_Container.cs:line 588
in '_client' ("public override ContainerResponse GetContainer(string url, string token, string container, Dictionary<string, string> headers, Dictionary<string, string> query, bool full_listing)") what happens is:
...
...
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.Name != "xml" &&
reader.Name != "container" &&
reader.Name != "object")
{
var key = reader.Name;
reader.Read();
info.Add(key, reader.Value); ////===== EXCEPTION HERE. NOTE: key = "subdir"
}
break;
Thanks
In Client.cs:
method
public ObjectResponse GetObject(string url, string token, string container, string name, Dictionary<string, string> headers, Dictionary<string, string> query):
looks like responsec.close() is missing before return??
Dictionary is a Set and complains about a duplicate items.
so in methods:
public ContainerResponse GetContainer(string url, string token, string container, Dictionary<string, string> headers, Dictionary<string, string> query, bool full_listing)
and
public AccountResponse GetAccount(string url, string token, Dictionary<string, string> headers, Dictionary<string, string> query, bool full_listing)
it will throw exception if info.ContainsKey(key) not checked before info.add ...
Looks like Client is inheriting from AbstractClient, but at this point there are only method signatures.. may be interface serves the purpose? No one can instiate an AbstractClient anyway, so ripple effect be minimal?
Looks like some common code can be pulled out and promoted to a Base Response class for various Responses. e.g
AccountResponse, AuthResponse .....??
Refactor code in client.cs into logical components. Looks like everything is in one file at the moment
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.