PhoenixKit.Modules.Publishing.Storage.Paths (phoenix_kit v1.7.38)

Copy Markdown View Source

Path management for publishing storage.

Handles root paths, group paths, legacy/new path resolution, and path utilities for the filesystem storage system.

Summary

Functions

Returns the absolute path for a relative blogging path. Handles per-blog legacy/new path resolution.

Cleans up empty directories going up from a path. Stops at the publishing/blogging root.

Removes the legacy root directory if it's empty.

Ensures the folder for a publishing group exists. For new groups, creates in the new "publishing" directory. For existing groups, uses their current location.

Returns the path for a specific publishing group, checking both new and legacy locations. Returns the path where the group actually exists, or the new path if it doesn't exist yet.

Returns whether there are any publishing groups still in the legacy location.

Checks if a specific publishing group is stored in the legacy "blogging" directory.

Returns the legacy blogging root path.

Migrates a publishing group from the legacy "blogging" directory to the new "publishing" directory. Returns {:ok, new_path} on success, {:error, reason} on failure.

Returns the new publishing root path.

Returns the root path for reading content. Prefers new "publishing" path, falls back to legacy "blogging" path. For writing new content, use write_root_path/0 instead.

Returns the write root path for creating new groups. Always returns the new "publishing" path.

Functions

absolute_path(relative_path)

@spec absolute_path(String.t()) :: String.t()

Returns the absolute path for a relative blogging path. Handles per-blog legacy/new path resolution.

cleanup_empty_dirs(path)

@spec cleanup_empty_dirs(String.t()) :: :ok

Cleans up empty directories going up from a path. Stops at the publishing/blogging root.

cleanup_empty_legacy_root()

@spec cleanup_empty_legacy_root() :: :ok

Removes the legacy root directory if it's empty.

ensure_group_root(group_slug)

@spec ensure_group_root(String.t()) :: :ok | {:error, term()}

Ensures the folder for a publishing group exists. For new groups, creates in the new "publishing" directory. For existing groups, uses their current location.

group_path(group_slug)

@spec group_path(String.t()) :: String.t()

Returns the path for a specific publishing group, checking both new and legacy locations. Returns the path where the group actually exists, or the new path if it doesn't exist yet.

has_legacy_groups?()

@spec has_legacy_groups?() :: boolean()

Returns whether there are any publishing groups still in the legacy location.

legacy_group?(group_slug)

@spec legacy_group?(String.t()) :: boolean()

Checks if a specific publishing group is stored in the legacy "blogging" directory.

legacy_root_path()

@spec legacy_root_path() :: String.t()

Returns the legacy blogging root path.

migrate_group(group_slug)

@spec migrate_group(String.t()) :: {:ok, String.t()} | {:error, term()}

Migrates a publishing group from the legacy "blogging" directory to the new "publishing" directory. Returns {:ok, new_path} on success, {:error, reason} on failure.

new_root_path()

@spec new_root_path() :: String.t()

Returns the new publishing root path.

root_path()

@spec root_path() :: String.t()

Returns the root path for reading content. Prefers new "publishing" path, falls back to legacy "blogging" path. For writing new content, use write_root_path/0 instead.

write_root_path()

@spec write_root_path() :: String.t()

Returns the write root path for creating new groups. Always returns the new "publishing" path.