Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,11 @@ def getquota(quota_root)
# Sends a {SETQUOTA command [RFC2087 §4.1]}[https://www.rfc-editor.org/rfc/rfc2087#section-4.1]
# along with the specified +quota_root+ and +storage_limit+. If
# +storage_limit+ is +nil+, resource limits are unset for that quota root.
# Otherwise, it sets the +STORAGE+ resource limit.
# If +storage_limit+ is a number, it sets the +STORAGE+ resource limit.
#
# imap.setquota "#user/alice", 100
# imap.getquota "#user/alice"
# # => [#<struct Net::IMAP::MailboxQuota mailbox="#user/alice" usage=54 quota=100>]
#
# Typically one needs to be logged in as a server admin for this to work.
#
Expand All @@ -1942,11 +1946,11 @@ def getquota(quota_root)
# resource type.
def setquota(quota_root, storage_limit)
if storage_limit.nil?
list = '()'
list = []
else
list = '(STORAGE ' + storage_limit.to_s + ')'
list = ["STORAGE", NumValidator.coerce_number64(storage_limit)]
end
send_command("SETQUOTA", quota_root, RawData.new(list))
send_command("SETQUOTA", quota_root, list)
end

# Sends a {SETACL command [RFC4314 §3.1]}[https://www.rfc-editor.org/rfc/rfc4314#section-3.1]
Expand Down
9 changes: 9 additions & 0 deletions test/net/imap/test_imap_quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ class IMAPQuotaTest < Net::IMAP::TestCase
rcvd_cmd = server.commands.pop
assert_equal "SETQUOTA", rcvd_cmd.name
assert_equal '"" ()', rcvd_cmd.args

assert_raise_with_message(Net::IMAP::DataFormatError,
"512.0 is not a valid number64") do
imap.setquota "INBOX", 512.0
end
assert_raise_with_message(Net::IMAP::DataFormatError,
'"512 620" is not a valid number64') do
imap.setquota "INBOX", "512 620"
end
end
end
end