NAME
Data::Downloader::File
DESCRIPTION
Represents a file managed by data::downloader.
METHODS
- storage_path
-
Returns the storage path for this file. This is calculated using the md5, the disk, and the storage root of the repository associated with this file.
- download
-
Download a file. This may be called as either a class method or an instance method. In the former case, it acts as a constructor, saving the object to the database.
Compute the URL if necessary. The URL may come from either an RSS feed (i.e. this file is already in the database) or may be computed using the url template.
Examples :
# make a new file, download it, store it, update symlinks my $file = Data::Downloader::File->download( md5 => "a46cee6a6d8df570b0ca977b9e8c3097", filename => "OMI-Aura_L2-OMTO3_2007m0220t0052-o13831_v002-2007m0220t221310.he5", repository => "local_repo", ); # equivalent my $file = Data::Downloader::File->new( md5 => "a46cee6a6d8df570b0ca977b9e8c3097", filename => "OMI-Aura_L2-OMTO3_2007m0220t0052-o13831_v002-2007m0220t221310.he5", repository => Data::Downloader::Repository->new( name => "local_repo" )->load->id, ); $file->download or die $file->error; # download all files for a certain feed $_->download for $feed->files;
Parameters : repository - a repository name fake - fake the download? skip_links - Skip making symlinks? <name> - value : value for the variable "<name>" in the url_template.
Returns :
true (1) - the file was downloaded or cached false (0) - there was an error (look in $obj->error for a message)
- decorate_tree
-
Put the links for a file within a single linktree. A tree may contain multiple symlinks for a file if there are metadata_transformations defined for this repository which transform a set of metadata into mutltiple sets of template parameters.
Parameters :
tree -- A DD::Linktree object
- makelinks
-
Make all the symlinks for a file by iterating through the linktrees and checking which satisfy the condition for the tree.
- load_file
-
loads the representation of a file in the database.
Arguments :
filename -- filename to be pruned
Returns : reference to self on success
- listlinks
-
List all the symlinks for a file
- remove
-
Remove this file from the disk, set "on_disk" to false and remove any symlinks too.
- purge
-
Remove this file and any information stored about it.
- check
-
Check a file and its symlinks and ensure that the database information represents what is stored on disk.
Arguments :
checksum -- if true, also compute the checksum fix -- if true, also attempt to fix anything broken
Returns :
nothing, just produces warnings and errors
- prune_links
-
Remove all the symlinks for a file matching a particular regular expression.
Arguments :
regex -- a regex to match against.
Returns :
false if a link could not be removed true if all links matching regex could be removed.
- load_from_urn
-
Load this object using the urn stored for it.