mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-10-10 21:13:10 +08:00
0d277b8550
* feat(strm): add local save permission mode - add private and shared permission modes for local STRM files - repair shared-mode directory and file permissions during generation - add permission handling tests Co-authored-by: Codex <267193182+codex@users.noreply.github.com> * fix(strm): respect deployment umask for local directories - remove application-level permission modes and chmod operations - create local STRM directories with umask-controlled permissions - preserve existing permissions and test the behavior Co-authored-by: Codex <267193182+codex@users.noreply.github.com> --------- Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package strm
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"testing"
|
|
)
|
|
|
|
func TestCreateLocalDirectory(t *testing.T) {
|
|
root := t.TempDir()
|
|
nested := filepath.Join(root, "library", "movie")
|
|
if err := createLocalDirectory(nested); err != nil {
|
|
t.Fatalf("createLocalDirectory() error = %v", err)
|
|
}
|
|
|
|
if _, err := os.Stat(nested); err != nil {
|
|
t.Fatalf("stat created directory: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestCreateLocalDirectoryPreservesExistingPermissions(t *testing.T) {
|
|
if runtime.GOOS == "windows" {
|
|
t.Skip("directory permission bits are not supported on Windows")
|
|
}
|
|
|
|
root := t.TempDir()
|
|
nested := filepath.Join(root, "library", "movie")
|
|
if err := os.MkdirAll(nested, 0o700); err != nil {
|
|
t.Fatalf("create existing directory: %v", err)
|
|
}
|
|
if err := createLocalDirectory(nested); err != nil {
|
|
t.Fatalf("createLocalDirectory() error = %v", err)
|
|
}
|
|
|
|
info, err := os.Stat(nested)
|
|
if err != nil {
|
|
t.Fatalf("stat existing directory: %v", err)
|
|
}
|
|
if got := info.Mode().Perm(); got != 0o700 {
|
|
t.Errorf("existing directory permissions = %#o, want %#o", got, 0o700)
|
|
}
|
|
}
|