Skip to content

Commit

Permalink
fix: preserve pandoc executable permissions on macOS during extraction
Browse files Browse the repository at this point in the history
This fixes an issue where pandoc becomes non-executable after installation
because Zipfile.extract() doesn't maintain file permissions.
  • Loading branch information
Oreoxmt committed Nov 21, 2024
1 parent d14cbc1 commit 552a1c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ The `tidocs merge` command provides a web interface for combining multiple relea

## Changelog

### v1.0.1

- Fix the issue that Pandoc becomes non-executable after installation on macOS because `Zipfile.extract()` doesn't maintain file permissions.
### v1.0.0
- Support merging multiple TiDB release notes Markdown files with HTML tables into one well-formatted Word document.
7 changes: 6 additions & 1 deletion src/tidocs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from hypercorn.asyncio import serve
from hypercorn.config import Config

from tidocs.pandoc_wrapper import Pandoc

APPS = {
"merge": "Merge Release Notes"
}
Expand Down Expand Up @@ -36,7 +38,7 @@ def launch_marimo_app(appname: str, host: str, port: int) -> None:


@click.command(no_args_is_help=True)
@click.version_option(version='1.0.0')
@click.version_option(version='1.0.1')
@click.argument(
"appname",
type=click.Choice(list(APPS.keys())),
Expand Down Expand Up @@ -79,6 +81,9 @@ def cli(appname: str, host: str, port: int) -> None:
$ tidocs merge --host 0.0.0.0 --port 9000
"""
if appname == "merge":
pandoc = Pandoc()
pandoc.install()
launch_marimo_app(appname, host, port)


Expand Down
3 changes: 2 additions & 1 deletion src/tidocs/pandoc_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def _progress_callback(count: int, block_size: int, total_size: int) -> None:
if basename == self.binary_name:
file.extract(info, tmp_dir_path)
extracted = tmp_dir_path / info.filename
extracted.chmod(info.external_attr >> 16)
break
elif archive_name.endswith(".tar.gz"):
with tarfile.open(archive_path, "r") as file:
Expand All @@ -163,7 +164,7 @@ def _progress_callback(count: int, block_size: int, total_size: int) -> None:
# Save version information after successful installation
self.save_version_info()
if not self.is_version_matched():
raise AssertionError("Pandoc installation failed.")
raise AssertionError("Pandoc version does not match requirements.")

return self.pandoc_binary

Expand Down

0 comments on commit 552a1c6

Please sign in to comment.