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

Cannot make cache folder #5

Closed
rusq opened this issue Aug 27, 2022 · 23 comments
Closed

Cannot make cache folder #5

rusq opened this issue Aug 27, 2022 · 23 comments

Comments

@rusq
Copy link

rusq commented Aug 27, 2022

Hi there, just read about this tool on note.com, it looks great, I was eager to try it out, but getting this error on macOS 15.2 monterey: "cannot make cache folder"

Steps to reproduce:

  1. Open SlackLogViewer
  2. From top left menu, choose "Open ZIP"
  3. Select file
  4. Error appears:

image

Expected behaviour:
4. File is loaded.

I read this article (with google translate), and understand that there's some difficulty for testing and debugging on macOS, but thought I'd create an issue to flag this.

Thank you :)

@thayakawa-gh
Copy link
Owner

Thank you for using my application.
Are you using the binary distributed for macOS? Or did you build it yourself? If the former, there may be some problems with the binary.
This error message appears when this app can not make some directories for storing temporary files under the "Cache" directory, which should exist under the current directory. On windows, for example, the directory structure is as follows:

SlackLogViewer/
    Cache/
    Resources/
    SlackLogViewer.exe
    ...

If there is no such directory in the current directory, I think we failed to create the directory in the binary.
Could you please create "Cache" directory manually and try again?

@cielavenir
Copy link
Contributor

or please use #4 (comment) binary

@rusq
Copy link
Author

rusq commented Aug 27, 2022

I was using the Release build "SlackLogViewer.v1.1.Beta-4.1-macos.tar.xz", will try the approach in the comment, thank you @thayakawa-gh @cielavenir ! Will let you know how it goes

@rusq
Copy link
Author

rusq commented Aug 27, 2022

Thank you! I used the binary linked by @cielavenir , it still did not work, but then I took it apart and recreated in the following way:

$ tree -L 2 .
.
|-- Frameworks
|   |-- QtConcurrent.framework
|   |   |-- QtConcurrent -> Versions/Current/QtConcurrent
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtCore.framework
|   |   |-- QtCore -> Versions/Current/QtCore
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtDBus.framework
|   |   |-- QtDBus -> Versions/Current/QtDBus
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtGui.framework
|   |   |-- QtGui -> Versions/Current/QtGui
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtNetwork.framework
|   |   |-- QtNetwork -> Versions/Current/QtNetwork
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtPdf.framework
|   |   |-- QtPdf -> Versions/Current/QtPdf
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtPositioning.framework
|   |   |-- QtPositioning -> Versions/Current/QtPositioning
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtPrintSupport.framework
|   |   |-- QtPrintSupport -> Versions/Current/QtPrintSupport
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtQml.framework
|   |   |-- QtQml -> Versions/Current/QtQml
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtQmlModels.framework
|   |   |-- QtQmlModels -> Versions/Current/QtQmlModels
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtQuick.framework
|   |   |-- QtQuick -> Versions/Current/QtQuick
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtQuickWidgets.framework
|   |   |-- QtQuickWidgets -> Versions/Current/QtQuickWidgets
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtSerialPort.framework
|   |   |-- QtSerialPort -> Versions/Current/QtSerialPort
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtSvg.framework
|   |   |-- QtSvg -> Versions/Current/QtSvg
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtVirtualKeyboard.framework
|   |   |-- QtVirtualKeyboard -> Versions/Current/QtVirtualKeyboard
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtWebChannel.framework
|   |   |-- QtWebChannel -> Versions/Current/QtWebChannel
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtWebEngineCore.framework
|   |   |-- Helpers -> Versions/Current/Helpers
|   |   |-- QtWebEngineCore -> Versions/Current/QtWebEngineCore
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtWebEngineWidgets.framework
|   |   |-- QtWebEngineWidgets -> Versions/Current/QtWebEngineWidgets
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- QtWidgets.framework
|   |   |-- QtWidgets -> Versions/Current/QtWidgets
|   |   |-- Resources -> Versions/Current/Resources
|   |   `-- Versions
|   |-- libquazip1-qt5.1.0.0.dylib
|   `-- libtbb.12.dylib
|-- Info.plist
|-- MacOS
|   |-- Cache
|   |-- Resources
|   |   |-- batsu.png
|   |   |-- cache.svg
|   |   |-- calendar.svg
|   |   |-- clear.svg
|   |   |-- document.png
|   |   |-- download.png
|   |   |-- download.svg
|   |   |-- downloading.png
|   |   |-- menu.png
|   |   |-- qt.conf
|   |   |-- regex.png
|   |   |-- search.png
|   |   `-- upper_lower_case.png
|   |-- SlackLogViewer
|   `-- settings.ini
`-- PlugIns
    |-- bearer
    |   `-- libqgenericbearer.dylib
    |-- iconengines
    |   `-- libqsvgicon.dylib
    |-- imageformats
    |   |-- libqgif.dylib
    |   |-- libqicns.dylib
    |   |-- libqico.dylib
    |   |-- libqjpeg.dylib
    |   |-- libqmacheif.dylib
    |   |-- libqmacjp2.dylib
    |   |-- libqpdf.dylib
    |   |-- libqtga.dylib
    |   |-- libqtiff.dylib
    |   |-- libqwbmp.dylib
    |   `-- libqwebp.dylib
    |-- platforminputcontexts
    |   `-- libqtvirtualkeyboardplugin.dylib
    |-- platforms
    |   `-- libqcocoa.dylib
    |-- position
    |   |-- libqtposition_cl.dylib
    |   |-- libqtposition_positionpoll.dylib
    |   `-- libqtposition_serialnmea.dylib
    |-- printsupport
    |   `-- libcocoaprintersupport.dylib
    |-- styles
    |   `-- libqmacstyle.dylib
    `-- virtualkeyboard
        |-- libqtvirtualkeyboard_hangul.dylib
        |-- libqtvirtualkeyboard_openwnn.dylib
        |-- libqtvirtualkeyboard_pinyin.dylib
        |-- libqtvirtualkeyboard_tcime.dylib
        `-- libqtvirtualkeyboard_thai.dylib

72 directories, 62 files

And it worked. Seems that the Cache and Resource folders need to be place alongside of the "SlackLogViewer" inside the MacOS directory within the "SlackLogViewer.app" .

Having created this folder structure, my observations were the following:

  1. If I run MacOS/SlackLogViewer executable directly, I can see the menu image and open the test archive with no problem - (btw it works very fast)!
  2. If I run the SlackLogViewer.app from the Finder, the issue with "cannot make cache folder" and menu is not visible.

@cielavenir
Copy link
Contributor

@rusq It seems extracting by Unarchiver is subject to quarantine (gatekeeper) and it causes weird cwd.

as shown in this movie, please extract by Archive Utility (or terminal "tar xf").

extract_slacklogviewer.mp4

@cielavenir
Copy link
Contributor

oh, need to run xattr -d com.apple.quarantine SlackLogViewer_macos.tar.xz before running Archive Utility...

@rusq
Copy link
Author

rusq commented Aug 29, 2022

Hi @cielavenir, thanks for the update, and sharing the video:

I tried it with the same result - recorded a video too: https://mega.nz/file/uzBSgRob#_WyX874j5dglxwODDm_VXTCUpKK7Yo7ZlQs8n4LG-bk (325.8 MB)

I did reset xattr, but I also used tar -xf (as seen on the video). I also shown how I did make it work.

The reason I'm looking at this project, as I'm thinking of listing it as an option to view Slack files in the slackdump project, before this, I'm trying to test it myself, to understand how easy is it to use. I personally really like it - it works much faster than slack-export-viewer.

@thayakawa-gh
Copy link
Owner

@rusq Perhaps I have to fix the codes accessing to caches and resources. I have been looking into the behavior of macOS and application bundle for a while, and it seems that these files cannot be accessed correctly in the same way as windows or linux. As you know, this application was just made for windows, not for macOS.

I was just testing to make it read the zip file that slackdump outputs (and found some problems). I will publish a new release including the fixes above in the near future.

@cielavenir
Copy link
Contributor

ah... thank you for the video, according to it your "current directory" is clearly /Volumes/Data. Somehow in my macbook the "current directory" is set to the same directory as .app.

I get sometimes confused as I'm not sure about GUI apps current directory on both macOS and Win and I don't know how to fix it...

Anyway with #8 , Cache and Resources are moved to SlackLogViewer.app/Content/MacOS and the "current directory" is forced there, and the issue should be gone.

Please check the "macos" binary in https://github.com/cielavenir/SlackLogViewer/actions/runs/2949398984

(As a "bonus", this SlackLogViewer.app can be put to /Applications)

@thayakawa-gh
Copy link
Owner

thayakawa-gh commented Aug 29, 2022

@cielavenir I think that using the absolute paths to Cache and Resources are more preferable than changing current directory in the application. It is possible that for some reason, for example, when users want to output some files to the working directory, the current directory becomes unchangeable. And, in the Qt app, there is an easy way to get the path.

By the way, is "MacOS" directory suitable for the location of the resources and temporary files? Some articles seems to suggest that such files should be placed in "Resources" directory.

@cielavenir
Copy link
Contributor

@thayakawa-gh actually SlackLogViewer.app/Contents/Resources/ and $HOME/Caches/SlackLogViewer are better dirs.

The thing is SlackLogViewer's entire directory access has to be rewritten.

@rusq
Copy link
Author

rusq commented Aug 29, 2022

Thanks for looking into this.

Probably, for cache dir, it would be possible to adopt the same logic used by os.UserCacheDir() function in golang? https://cs.opensource.google/go/go/+/refs/tags/go1.19:src/os/file.go;l=405
I don't have much experience developing GUI apps for MacOS either, and I'm not sure if this would be accessible by the "App".

Or, probably, $TEMP could be considered?

@cielavenir
Copy link
Contributor

entire directory access has to be rewritten.

@thayakawa-gh to be clear, I mean there are so many hardcoded Cache/ and Resource/. Could you put these string into a function? (otherwise I still feel chdir is quickest workaround)

@thayakawa-gh
Copy link
Owner

Please check the test branch. All hard-coded paths have been rewritten, and the paths to Cache and Resources are defined in lines 13-29 of main.cpp. I'm not sure whether QDir::temp() (returns $TMPDIR or /tmp) or $HOME/Cache is more suitable.
It was not much effort compared to the difficulty of creating a new feature. In addition, it was a good opportunity to rewrite foolish hard-coded paths.

The binary for macOS is here (thanks to @cielavenir).

However, I have a hard time deciding where to store caches. I use the function of the cache as practially a backup of files (and recommend users to do so in this article). If they are stored in the temporary dir, there is a possibility that users may unintentionally delete them. Should we allow users to choose where to store them? For example, place under the same directory as the Resources by default and make it rewritable in setting.ini.

@cielavenir
Copy link
Contributor

@thayakawa-gh the binary does not work...

direct execution says this QCoreApplication::applicationDirPath: Please instantiate the QApplication object first

@thayakawa-gh
Copy link
Owner

@cielavenir Thank you for testing.
Hmm... Qt behavior on macOS seems to be a bit different from that on windows.
I have rearranged the order of the calls. Could you try this binary again?

@cielavenir
Copy link
Contributor

This one works

@rusq ok on your machine as well?

@rusq
Copy link
Author

rusq commented Aug 30, 2022

@cielavenir @thayakawa-gh It works, straight out of the archive! Thank you for resolving this :)

image

@rusq
Copy link
Author

rusq commented Aug 30, 2022

I will have couple of more suggestions, if you don't mind, will describe in separate issues.

Thanks for resolving this so quickly - it's a great product and I personally think it's much better and more convenient to use then other viewers out there in both speed of operation and the code quality.

There's a high interest in export viewers, because slack has introduced this silly 90-day policy on the free accounts, where any message older than 90 days is hidden, so people are exporting their workspaces.

I'll post a link to the SlackLogViewer in the slackdump repo.

@rusq rusq closed this as completed Aug 30, 2022
@cielavenir
Copy link
Contributor

@rusq that's nice

@thayakawa-gh thank you for the support

@thayakawa-gh
Copy link
Owner

thayakawa-gh commented Aug 31, 2022

@rusq I'm glad I could help you. @cielavenir Thank you for your investigation.
I will release the branch after a small fix (QDir::tmp() seems not to be a suitable location for the Cache dir. The logic in os.UserCacheDir() @rusq suggested may be a good solution).

Comments and Suggestions are always welcome, please feel free to contact me. However, I will be very busy for the next half year, so I don't know if I will be able to accommodate you right away...

@rusq
Copy link
Author

rusq commented Aug 31, 2022

Comments and Suggestions are always welcome, please feel free to contact me. However, I will be very busy for the next half year, so I don't know if I will be able to accommodate you right away...

Thank you! Of course, I understand. Open source projects are like collective farm - everyone is responsible for their own happiness 😂 Maybe I'll refresh my C++ knowledge and would be able to contribute at some point, I have QtCreator installed on my machine, but did not have any practical application for it. Maybe that's the chance!

I mentioned this project, along with what I'm to suggest in the discussion that was started by one of the contributors to slackdump - maybe you could share some insights and suggestions too?rusq/slackdump#127

@thayakawa-gh
Copy link
Owner

@rusq I browsed the discussion and found it interesting. I will comment if I come up something.

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

No branches or pull requests

3 participants