[archiver] Add support for excluding extension-stripped file-names

This commit is contained in:
Ciprian Dorin Craciun 2018-11-20 14:49:43 +02:00
parent 583367de9a
commit 9fbae9fccc

View file

@ -37,6 +37,7 @@ type context struct {
storedFiles map[[2]uint64][2]string storedFiles map[[2]uint64][2]string
compress string compress string
includeIndex bool includeIndex bool
includeStripped bool
includeEtag bool includeEtag bool
includeFileListing bool includeFileListing bool
includeFolderListing bool includeFolderListing bool
@ -103,13 +104,15 @@ func archiveFile (_context *context, _pathResolved string, _pathInArchive string
} }
} }
for _, _suffix := range StripSuffixes { if _context.includeStripped {
if strings.HasSuffix (_pathInArchive, _suffix) { for _, _suffix := range StripSuffixes {
_pathInArchive := _pathInArchive [: len (_pathInArchive) - len (_suffix)] if strings.HasSuffix (_pathInArchive, _suffix) {
if _error := archiveReference (_context, NamespaceFilesContent, _pathInArchive, _fingerprintContent, _fingerprintMeta); _error != nil { _pathInArchive := _pathInArchive [: len (_pathInArchive) - len (_suffix)]
return _error if _error := archiveReference (_context, NamespaceFilesContent, _pathInArchive, _fingerprintContent, _fingerprintMeta); _error != nil {
return _error
}
break
} }
break
} }
} }
@ -628,6 +631,7 @@ func main_0 () (error) {
var _archiveFile string var _archiveFile string
var _compress string var _compress string
var _includeIndex bool var _includeIndex bool
var _includeStripped bool
var _includeEtag bool var _includeEtag bool
var _includeFileListing bool var _includeFileListing bool
var _includeFolderListing bool var _includeFolderListing bool
@ -667,6 +671,7 @@ func main_0 () (error) {
--compress <gzip | brotli | identity> --compress <gzip | brotli | identity>
--exclude-index --exclude-index
--exclude-strip
--exclude-etag --exclude-etag
--exclude-file-listing --exclude-file-listing
@ -681,6 +686,7 @@ func main_0 () (error) {
_archiveFile_0 := _flags.String ("archive", "", "") _archiveFile_0 := _flags.String ("archive", "", "")
_compress_0 := _flags.String ("compress", "", "") _compress_0 := _flags.String ("compress", "", "")
_excludeIndex_0 := _flags.Bool ("exclude-index", false, "") _excludeIndex_0 := _flags.Bool ("exclude-index", false, "")
_excludeStripped_0 := _flags.Bool ("exclude-strip", false, "")
_excludeEtag_0 := _flags.Bool ("exclude-etag", false, "") _excludeEtag_0 := _flags.Bool ("exclude-etag", false, "")
_excludeFileListing_0 := _flags.Bool ("include-file-listing", false, "") _excludeFileListing_0 := _flags.Bool ("include-file-listing", false, "")
_includeFolderListing_0 := _flags.Bool ("exclude-folder-listing", false, "") _includeFolderListing_0 := _flags.Bool ("exclude-folder-listing", false, "")
@ -692,6 +698,7 @@ func main_0 () (error) {
_archiveFile = *_archiveFile_0 _archiveFile = *_archiveFile_0
_compress = *_compress_0 _compress = *_compress_0
_includeIndex = ! *_excludeIndex_0 _includeIndex = ! *_excludeIndex_0
_includeStripped = ! *_excludeStripped_0
_includeEtag = ! *_excludeEtag_0 _includeEtag = ! *_excludeEtag_0
_includeFileListing = ! *_excludeFileListing_0 _includeFileListing = ! *_excludeFileListing_0
_includeFolderListing = *_includeFolderListing_0 _includeFolderListing = *_includeFolderListing_0
@ -727,6 +734,7 @@ func main_0 () (error) {
storedFiles : make (map[[2]uint64][2]string, 16 * 1024), storedFiles : make (map[[2]uint64][2]string, 16 * 1024),
compress : _compress, compress : _compress,
includeIndex : _includeIndex, includeIndex : _includeIndex,
includeStripped : _includeStripped,
includeEtag : _includeEtag, includeEtag : _includeEtag,
includeFileListing : _includeFileListing, includeFileListing : _includeFileListing,
includeFolderListing : _includeFolderListing, includeFolderListing : _includeFolderListing,