lib/cloudfiles/container.rb in cloudfiles-1.4.5 vs lib/cloudfiles/container.rb in cloudfiles-1.4.6

- old
+ new

@@ -61,11 +61,11 @@ # container.count # => 3 def populate # Get the size and object count response = self.connection.cfreq("HEAD",@storagehost,@storagepath+"/",@storageport,@storagescheme) - raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "204") + raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code =~ /^20/) @bytes = response["x-container-bytes-used"].to_i @count = response["x-container-object-count"].to_i # Get the CDN-related details response = self.connection.cfreq("HEAD",@cdnmgmthost,@cdnmgmtpath,@cdnmgmtport,@cdnmgmtscheme) @@ -211,11 +211,11 @@ # # container.object_exists?('badfile.txt') # => false def object_exists?(objectname) response = self.connection.cfreq("HEAD",@storagehost,"#{@storagepath}/#{URI.encode(objectname).gsub(/&/,'%26')}",@storageport,@storagescheme) - return (response.code == "204")? true : false + return (response.code =~ /^20/)? true : false end # Creates a new CloudFiles::StorageObject in the current container. # # If an object with the specified name exists in the current container, that object will be returned. Otherwise, @@ -237,10 +237,10 @@ # container.delete_object('nonexistent_file.txt') # => NoSuchObjectException: Object nonexistent_file.txt does not exist def delete_object(objectname) response = self.connection.cfreq("DELETE",@storagehost,"#{@storagepath}/#{URI.encode(objectname).gsub(/&/,'%26')}",@storageport,@storagescheme) raise NoSuchObjectException, "Object #{objectname} does not exist" if (response.code == "404") - raise InvalidResponseException, "Invalid response code #{response.code}" unless (response.code == "204") + raise InvalidResponseException, "Invalid response code #{response.code}" unless (response.code =~ /^20/) true end # Makes a container publicly available via the Cloud Files CDN and returns true upon success. Throws NoSuchContainerException # if the container doesn't exist or if the request fails.