cweidenkeller / csharp-swift

A light Rest Wrapper for OpenStack Swift
MIT License
10 stars 5 forks source link

System.ArgumentException: An item with the same key has already been added #2

Open horacioj opened 12 years ago

horacioj commented 12 years ago

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

horacioj commented 12 years ago

any clue?

horacioj commented 12 years ago

?

edwardt commented 12 years ago

should be addressed by https://github.com/cweidenkeller/csharp-swift/issues/5