You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

23 lines
683 B

package asset
import (
"XProxy/cmd/common"
log "github.com/sirupsen/logrus"
"path"
)
func extractFile(archive string, geoFile string, targetDir string) { // extract `.dat` file into targetDir
filePath := path.Join(targetDir, geoFile)
if common.IsFileExist(filePath) {
log.Debugf("Asset %s exist -> skip extract", geoFile)
return
}
log.Infof("Extract asset file -> %s", filePath)
common.RunCommand("tar", "xf", archive, geoFile, "-C", targetDir)
}
func Load(assetFile string, assetDir string) {
common.CreateFolder(assetDir)
extractFile(assetFile, "geoip.dat", assetDir)
extractFile(assetFile, "geosite.dat", assetDir)
}