Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temporary directory remains on disk #436

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vips/govips.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func Startup(config *Config) {
panic(fmt.Sprintf("Failed to start vips code=%v", err))
}

createTemporaryDirectoryOrPanic()
initializeICCProfiles()

running = true
Expand Down
27 changes: 20 additions & 7 deletions vips/icc_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,24 @@ var (
0x00, 0x20, 0x63, 0xcf, 0x8f, 0xf0, 0x65, 0x87, 0x4e, 0xf6, 0x00, 0x00,
}

temporaryDirectory = temporaryDirectoryOrPanic()
SRGBV2MicroICCProfilePath = filepath.Join(temporaryDirectory, "srgb_v2_micro.icc")
SGrayV2MicroICCProfilePath = filepath.Join(temporaryDirectory, "sgray_v2_micro.icc")
SRGBIEC6196621ICCProfilePath = filepath.Join(temporaryDirectory, "srgb_iec61966_2_1.icc")
GenericGrayGamma22ICCProfilePath = filepath.Join(temporaryDirectory, "generic_gray_gamma_2_2.icc")
temporaryDirectory string
SRGBV2MicroICCProfilePath string
SGrayV2MicroICCProfilePath string
SRGBIEC6196621ICCProfilePath string
GenericGrayGamma22ICCProfilePath string
)

func initializeICCProfiles() {

if temporaryDirectory == "" {
createTemporaryDirectoryOrPanic()
}

SRGBV2MicroICCProfilePath = filepath.Join(temporaryDirectory, "srgb_v2_micro.icc")
SGrayV2MicroICCProfilePath = filepath.Join(temporaryDirectory, "sgray_v2_micro.icc")
SRGBIEC6196621ICCProfilePath = filepath.Join(temporaryDirectory, "srgb_iec61966_2_1.icc")
GenericGrayGamma22ICCProfilePath = filepath.Join(temporaryDirectory, "generic_gray_gamma_2_2.icc")

storeIccProfile(SRGBV2MicroICCProfilePath, sRGBV2MicroICCProfile)
storeIccProfile(SGrayV2MicroICCProfilePath, sGrayV2MicroICCProfile)
storeIccProfile(SRGBIEC6196621ICCProfilePath, sRGBIEC6196621ICCProfile)
Expand All @@ -665,8 +675,11 @@ func storeIccProfile(path string, data []byte) {
}
}

func temporaryDirectoryOrPanic() string {
temporaryDirectory, err := os.MkdirTemp("", "govips-")
func createTemporaryDirectoryOrPanic() string {

tmpDir, err := os.MkdirTemp("", "govips-")
temporaryDirectory = tmpDir // assign to global variable

if err != nil {
panic(fmt.Sprintf("Couldn't create temporary directory: %v", err.Error()))
}
Expand Down
Loading