cached_downloader.go
func New(
	downloader *Downloader,
	cache *FileCache,
	transformer CacheTransformer,
) *cachedDownloader {
	os.MkdirAll(cache.CachedPath, 0770)
	return &cachedDownloader{
		cache:         cache,
		cacheLocation: filepath.Join(cache.CachedPath, "saved_cache.json"),
		uncachedPath:  createTempCachedDir(cache.CachedPath),
		downloader:    downloader,
		transformer:   transformer,

		lock:       &sync.Mutex{},
		inProgress: map[string]chan struct{}{},
	}
}
func New(
	downloader *Downloader,
	cache *FileCache,
	transformer CacheTransformer,
) *cachedDownloader {
	os.MkdirAll(cache.CachedPath, 0770)
	return &cachedDownloader{
		cache:         cache,
		cacheLocation: filepath.Join(cache.CachedPath, "saved_cache.json"),
		uncachedPath:  createTempCachedDir(cache.CachedPath),
		downloader:    downloader,
		transformer:   transformer,

		lock:       &sync.Mutex{},
		inProgress: map[string]chan struct{}{},
	}
}
// A transformer function can be used to do post-download
// processing on the file before it is stored in the cache.