Skip to content

Support custom temporary directory#166

Merged
AndreasSko merged 5 commits intomasterfrom
fix_tmpdir
Jun 1, 2025
Merged

Support custom temporary directory#166
AndreasSko merged 5 commits intomasterfrom
fix_tmpdir

Conversation

@AndreasSko
Copy link
Copy Markdown
Owner

@AndreasSko AndreasSko commented Jun 1, 2025

Users on iOS reported issues when importing backups:

Error while creating temporary directory: mkdir /var/folders/t_/0w12llq155s3bcljc16_hj_c0000gn/T/go-jwlm1513177742: operation not permitted

It looks like Go might now always be able to determine the correct path for temporary directories.

With this PR we now support customizing the tempDir. This will be used in the iOS app to create a tempDir via Swift and then provide it to go-jwlm.

Other changes

Remove ioutil

The package has been deprecated.

Workaround for flaky test

Upgrade to Go 1.24

🐛 Files not closed in catalog unit tests

The tests started to fail on Windows with this error:

--- FAIL: TestCatalogNeedsUpdate (1.48s)
    testing.go:1267: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestCatalogNeedsUpdate734870388\001\catalog.db: The process cannot access the file because it is being used by another process.
--- FAIL: TestCatalogExists (1.47s)
    testing.go:1267: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestCatalogExists580267843\001\catalog.db: The process cannot access the file because it is being used by another process.
--- FAIL: Test_DownloadCatalog (1.58s)
    testing.go:1267: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\Test_DownloadCatalog2314487335\001\catalog.db: The process cannot access the file because it is being used by another process.

The issue was that the files were not closed, so the cleanup couldn't delete the files.

Users on iOS reported issues when
importing backups:

> Error while creating temporary directory: mkdir /var/folders/t_/0w12llq155s3bcljc16_hj_c0000gn/T/go-jwlm1513177742: operation not permitted

It looks like Go might now always
be able to determine the correct
path for temporary directories.

With this PR we now support
customizing the tempDir. This will
be used in the iOS app to create
a tempDir via Swift and then providing
it to go-jwlm.
The package has been deprecated.
@coveralls
Copy link
Copy Markdown

coveralls commented Jun 1, 2025

Coverage Status

coverage: 89.309% (-0.03%) from 89.341%
when pulling 0aaf953 on fix_tmpdir
into e228e49 on master.

The tests started to fail on Windows
with this error:

```
--- FAIL: TestCatalogNeedsUpdate (1.48s)
    testing.go:1267: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestCatalogNeedsUpdate734870388\001\catalog.db: The process cannot access the file because it is being used by another process.
--- FAIL: TestCatalogExists (1.47s)
    testing.go:1267: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestCatalogExists580267843\001\catalog.db: The process cannot access the file because it is being used by another process.
--- FAIL: Test_DownloadCatalog (1.58s)
    testing.go:1267: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\Test_DownloadCatalog2314487335\001\catalog.db: The process cannot access the file because it is being used by another process.
```

The issue was that the files were not
closed, so the cleanup couldn't
delete the files.
@AndreasSko AndreasSko merged commit fbf1417 into master Jun 1, 2025
9 checks passed
@AndreasSko AndreasSko deleted the fix_tmpdir branch June 1, 2025 14:42
AndreasSko added a commit to AndreasSko/library-merger that referenced this pull request Jun 1, 2025
As explained in
AndreasSko/go-library-merger#166
users reported issues with the
temporary directory when importing
backups.

With this commit we explicitly set
the temporary directory that is
directly provided by the fileManager.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants