class Maildir
- Maildir
- Reference
- Object
Overview
Class for generating unique file names for new messages
Included Modules
- Comparable(Maildir)
Defined in:
maildir.crmessage.cr
serializer/base.cr
serializer/json.cr
serializer/yaml.cr
unique_name.cr
version.cr
Constant Summary
-
DEFAULT_SERIALIZER =
Maildir::Serializer::Base.new -
Default serializer.
-
FOLDER_MARKER =
"maildirfolder" -
FOLDER_PREFIX =
"." -
Maildir++ folders live in the root maildir as sibling directories whose name is the folder name prefixed with a dot; nesting is expressed by joining the name components with a dot too (".Parent.Child"). Every folder also carries an empty "maildirfolder" file, so that other tools recognize it as a folder rather than as a maildir in its own right.
-
FOLDER_SEPARATOR =
"." -
SUBDIRS =
{"tmp", "new", "cur"} -
VERSION =
"6.1.0"
Constructors
-
.new(path, create = true)
Create a new maildir at +path+.
Class Method Summary
-
.fsync=(fsync : Bool)
Sets whether messages are fsynced before delivery.
-
.fsync? : Bool
Returns true if messages are fsynced before delivery.
-
.maildir?(path) : Bool
Returns true if +path+ holds a maildir, i.e.
-
.serializer : Maildir::Serializer::Base
Gets the default serializer.
-
.serializer=(serializer : Maildir::Serializer::Base)
Sets the default serializer.
Instance Method Summary
-
#<=>(other : self)
Compare maildirs by their paths.
-
#add(data)
Writes data object out as a new message.
-
#create_directories
Ensure subdirectories exist.
- #cur_path
-
#delete(key)
Deletes the message for key by calling destroy() on the message.
-
#folder(name : String, create = true) : Maildir
Returns the maildir for the named subfolder of this one, creating the directories of the whole chain unless +create+ is false.
-
#folder? : Bool
Returns true if this maildir is a Maildir++ folder of another maildir: its directory name is dot-prefixed and it sits inside a maildir.
-
#folder_name : String | Nil
The Maildir++ name of this folder ("a", "a.x"), or nil for a root maildir.
-
#folders : Array(Maildir)
Returns this maildir's immediate subfolders, sorted by path.
-
#get(key)
Returns a message object for key
-
#get_stale_tmp(time : Time = Time.utc - 36.hours)
Finds messages in the tmp folder that have not been modified since +time+.
-
#hash(hasher)
See
Object#hash(hasher) -
#inspect(io : IO) : Nil
Friendly inspect method
-
#list(dir : String, options = {} of Symbol => String | Int32 | ::Nil)
Returns an array of messages from the "new" or "cur" directory, sorted by key.
- #new_path
-
#parent : Maildir | Nil
The maildir this folder is nested in, or nil for a root maildir.
- #path : String
-
#root : Maildir
The root maildir this folder belongs to.
-
#serializer : Maildir::Serializer::Base
Returns own serializer or falls back to the default one.
- #serializer=(serializer : Maildir::Serializer::Base | Nil)
-
#tmp_path
define methods tmp_path, new_path, & cur_path
Constructor Detail
Create a new maildir at +path+. If +create+ is true, will ensure that the required subdirectories exist.
Class Method Detail
Sets whether messages are fsynced before delivery. Turning this off trades the crash-safety guarantee above for throughput, which can be worth it on rotational or network storage when the data is reproducible anyway.
Returns true if +path+ holds a maildir, i.e. has the tmp, new and cur subdirectories.
Instance Method Detail
Writes data object out as a new message. Returns a Maildir::Message. See Maildir::Message.create for more.
Ensure subdirectories exist. This can safely be called multiple times and from several processes at once, but must hit the disk. Avoid calling this if you're certain the directories exist.
Returns the maildir for the named subfolder of this one, creating the directories of the whole chain unless +create+ is false. Names nest with a dot, so these two are the same folder: maildir.folder("a.x") maildir.folder("a").folder("x")
Returns true if this maildir is a Maildir++ folder of another maildir: its directory name is dot-prefixed and it sits inside a maildir. The second condition is what keeps a root maildir which merely lives at a dot-path (say "~/.maildir") from being taken for a folder of its parent directory.
The answer is settled once, on first use, so a maildir doesn't change its mind halfway through if the surrounding directories change.
The Maildir++ name of this folder ("a", "a.x"), or nil for a root maildir.
Returns this maildir's immediate subfolders, sorted by path. Deeper descendants are reached by asking those folders in turn.
Finds messages in the tmp folder that have not been modified since +time+. +time+ defaults to 36 hours ago.
Returns an array of messages from the "new" or "cur" directory, sorted by key. If options[:flags] is specified and dir is "cur", returns only the messages carrying exactly those flags.
E.g. maildir.list("cur", {:flags => "F"}) # => lists all messages with flag "F" maildir.list("cur", {:flags => "FS"}) # => lists all messages with flags "F" and "S"; flags must be specified in ascending ASCII order ("FS" and not "SF") maildir.list("cur", {:flags => ""}) # => lists all messages without any flags This option does not work for the "new" directory
If options[:limit] is specified, returns only so many keys.
E.g. maildir.list("new") # => all new messages maildir.list("cur", {:limit => 10}) # => 10 oldest messages in cur
The maildir this folder is nested in, or nil for a root maildir.
The root maildir this folder belongs to. Returns self if this maildir is already a root.
Returns own serializer or falls back to the default one. Deliberately does
not memoize, so that a later change of Maildir.serializer is picked up by
maildirs which don't have a serializer of their own.