Documentation ¶
Index ¶
- func BagNameFromTarFileName(pathToTarFile string) string
- func Base64EncodeMd5(md5Digest string) (string, error)
- func BucketNameAndKey(uri string) (string, string)
- func CleanBagName(bagName string) string
- func CleanString(str string) string
- func ContainsControlCharacter(str string) bool
- func DeleteFromStringList(list []string, item string) []string
- func GetInstitutionFromBagName(bagName string) (string, error)
- func HasSavableName(filename string) bool
- func IntListContains(list []int, item int) bool
- func IsGlacierDeepArchive(storageOption string) bool
- func LooksLikeEscapedControl(str string) bool
- func LooksLikeJunkFile(filename string) bool
- func LooksLikeURL(url string) bool
- func LooksLikeUUID(uuid string) bool
- func Min(x, y int) int
- func OwnerOf(bucketName string) (institution string)
- func PointerToString(strPointer *string) string
- func RestorationBucketFor(institution string, restoreToTestBuckets bool) (bucketName string)
- func StringListContains(list []string, item string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BagNameFromTarFileName ¶
BagNameFromTarFileName returns the bag name of the specified tar file. This works even for tar files with names like 'test.edu.my_bag.b01.of12.tar'. That will return 'test.edu.my_bag'.
func Base64EncodeMd5 ¶
Base64EncodeMd5 returns a base64-encoded md5 digest. The is the format S3 wants.
func BucketNameAndKey ¶
BucketNameAndKey returns the bucket name and key of the specified url, which is expected to be an S3 URI.
func CleanBagName ¶
CleanBagName returns the clean bag name. That's the tar file name minus the tar extension and any ".bagN.ofN" suffix.
func CleanString ¶
CleanString cleans a string we might find a config file, trimming leading and trailing spaces, single quotes and double quoted. Note that leading and trailing spaces inside the quotes are not trimmed.
func ContainsControlCharacter ¶
ContainsControlCharacter returns true if string str contains a Unicode control character. We use this to test file names, which should not contain control characters.
func DeleteFromStringList ¶
DeleteFromStringList deletes item from list and returns a new slice.
func GetInstitutionFromBagName ¶
GetInstitutionFromBagName returns the instution name from the bag name, or an error if the bag name does not contain the institution name. For example, "virginia.edu.bag_of_videos.tar" returns "virginia.edu" and no errors. "virginia.edu.bag_of_videos" returns the same thing. But "bag_of_videos.tar" or "virginia.bag_of_videos.tar" returns an error because the institution identifier is missing from the bag name.
func HasSavableName ¶
HasSavableNamereturns true if the file name indicates this is something we should save to long-term storage. As of late March, 2016, we save everything in the bag except bagit.txt, manifest-<algo>.txt and tagmanifest-<algo>.txt. Those files we don't save will be reconstructed when the bag is restored.
Param filename should be the relative path of the file within the bag. For example, "tagmanifest-sha256.txt" or "data/images/photo_01.jpg". This is important, because a file called "manifest-md5.txt" will return false (indicating it should not be saved), while a file called "data/manifest-md5.txt" will return true, because its file path indicates it's part of the payload.
We reconstruct bagit.txt because we may have moved to a newer version by the time the file is restored. We reconstruct manifests and tag manifests because payload files and tag files may be deleted or overwritten by the depositor between initial ingest and restoration.
And did you know both savable and saveable are correct? I chose the former to reduce the size of our compiled binary by one byte. That could save us pennies over the next 10,000 years.
func IntListContains ¶
IntListContains returns true if the list of ints contains item.
func IsGlacierDeepArchive ¶
IsGlacierDeepArchive returns true if bucketName matches any of our Glacier Deep Archive storage buckets.
func LooksLikeEscapedControl ¶
LooksLikeEscapedControl returns true if string str contains something that looks like an escaped UTF-8 control character. The Mac OS file system seems to silently escape UTF-8 control characters. That causes problems when we try to copy a file over to another file system that won't accept the control character in a file name. The bag validator looks for file names matching these patterns and rejects them.
func LooksLikeJunkFile ¶
LooksLikeJunkFile returns true if the filename looks like a MacOS junk file. These are dot-underscore files that contain extended file attributes. These files are often unintentionally included in tarred bags created on MacOS. They may not appear in the manifests, and that will cause bag validation to fail. Part of https://www.pivotaltracker.com/story/show/151265762
func LooksLikeURL ¶
LooksLikeURL returns true if url looks like a URL.
func LooksLikeUUID ¶
LooksLikeUUID returns true if uuid looks like a valid UUID.
func Min ¶
Min returns the minimum of x or y. The Math package has this function but you have to cast to floats.
func OwnerOf ¶
OwnerOf returns the domain name of the institution that owns the specified bucket. For example, if bucketName is 'aptrust.receiving.unc.edu' the return value will be 'unc.edu'.
func PointerToString ¶
PointerToString returns the string pointed to, or an empty string if the pointer is nil.
func RestorationBucketFor ¶
RestorationBucketFor returns the name of the specified institution's restoration bucket. E.g. institution 'unc.edu' returns bucketName 'aptrust.restore.unc.edu'. The second param, restoreToTestBuckets, is set the in the config json file and accessible through Config.RestoreToTestBuckets. It should be true everywhere except in the production environment. If true, this will return 'aptrust.restore.test.unc.edu'.
func StringListContains ¶
StringListContains returns true if the list of strings contains item.
Types ¶
This section is empty.