More work on the transfer kitten

This commit is contained in:
Kovid Goyal
2023-04-28 17:25:17 +05:30
parent a3640b21ac
commit be7f276d3e
4 changed files with 310 additions and 1 deletions

View File

@@ -63,3 +63,18 @@ func run_with_paths(cwd, home string, f func()) {
defer func() { global_cwd, global_home = "", "" }()
f()
}
func should_be_compressed(path string) bool {
ext := strings.ToLower(filepath.Ext(path))
if ext != "" {
switch ext[1:] {
case "zip", "odt", "odp", "pptx", "docx", "gz", "bz2", "xz", "svgz":
return false
}
}
mt := utils.GuessMimeType(path)
if strings.HasSuffix(mt, "+zip") || (strings.HasPrefix(mt, "image/") && mt != "image/svg+xml") || strings.HasPrefix(mt, "video/") {
return false
}
return true
}