PPTX.jl
PPTX.jl copied to clipboard
testing the read-only permission of Pkg.add
To make sure we never again miss something like https://github.com/ASML-Labs/PPTX.jl/issues/45
Codecov Report
Merging #47 (d4f9257) into main (1f1adda) will not change coverage. Report is 1 commits behind head on main. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## main #47 +/- ##
=======================================
Coverage 94.62% 94.62%
=======================================
Files 10 10
Lines 521 521
=======================================
Hits 493 493
Misses 28 28
Files Changed | Coverage Δ | |
---|---|---|
src/write.jl | 87.70% <100.00%> (ø) |
Hmm, I cannot set chmod(edited_template_path, 0o444; recursive=true)
on ubuntu in the test?
IOError: stat("/tmp/jl_MFdsV3/no-slides/[Content_Types].xml"): permission denied (EACCES)
If chmod("/tmp/jl_MFdsV3/no-slides", 0o444, recursive=true)
sets the directory first to be read-only, then stat("/tmp/jl_MFdsV3/no-slides/[Content_Types].xml")
fails.
mkdir foo
touch > foo/bar
chmod u-x foo
stat foo/bar
gives me stat: cannot stat ‘foo/bar’: Permission denied
. The directory needs to have execute bit in order to files be accessed.
One could set chmod(unzipped_dir, 0o770, recursive=true)
to make sure files are writable and directories are executable in case the template was copied to the temp directory from files inside the PPTX-package (or some other directory without write bits.
Or maybe a bit better not to put execute bit on the files
for (root, dirs, files) in walkdir(unzipped_dir)
for dir in dirs
chmod(dir, 0x770)
end
for file in files
chmod(file, 0o660)
end
end
Addendum: On PPTX 0.6.5 that did not set the permissions on [Content_Types].xml
using PPTX
pres = Presentation()
write("foo.pptx", pres, template_path=joinpath(PPTX.TEMPLATE_DIR, "no-slides.pptx")) # works
write("foo.pptx", pres, template_path=joinpath(PPTX.TEMPLATE_DIR, "no-slides")) # fails