feat: raise the self-host job retention default to 24h and surface it in the UI
Issue #46 round two: the 1h sweep kept deleting finished projects under self-hosters who never touched their env. The disk is already bounded by OUTPUT_MAX_GB / UPLOADS_MAX_GB, so age can afford to be generous. Cloud keeps the tight default because clips are archived to R2 on completion. The results panel now tells self-host users how long their clips live and which env var controls it, and the restorable-session window follows the new default.
This commit is contained in:
parent
1cbd22991c
commit
d0e1f5adfd
3 changed files with 28 additions and 3 deletions
10
app.py
10
app.py
|
|
@ -47,7 +47,6 @@ MAX_FILE_SIZE_MB = 2048 # 2GB limit
|
||||||
# where covers, sounds and hashtags actually get chosen. The UI must say so —
|
# where covers, sounds and hashtags actually get chosen. The UI must say so —
|
||||||
# a user who expects a published post and finds a draft will read it as a bug.
|
# a user who expects a published post and finds a draft will read it as a bug.
|
||||||
TIKTOK_POST_MODE = os.environ.get("TIKTOK_POST_MODE", "MEDIA_UPLOAD").strip()
|
TIKTOK_POST_MODE = os.environ.get("TIKTOK_POST_MODE", "MEDIA_UPLOAD").strip()
|
||||||
JOB_RETENTION_SECONDS = int(os.environ.get("JOB_RETENTION_SECONDS", "3600")) # job/file retention (issue #46)
|
|
||||||
# Ceiling for the working directory once it lives on a persistent volume: the
|
# Ceiling for the working directory once it lives on a persistent volume: the
|
||||||
# age-based sweep alone can't stop a burst of long videos from filling the disk.
|
# age-based sweep alone can't stop a burst of long videos from filling the disk.
|
||||||
# 0 disables the cap.
|
# 0 disables the cap.
|
||||||
|
|
@ -65,6 +64,14 @@ DISABLE_YOUTUBE_URL = os.environ.get("DISABLE_YOUTUBE_URL", "false").lower() in
|
||||||
# when BILLING_ENABLED is set. With the flag off, the app behaves exactly as the
|
# when BILLING_ENABLED is set. With the flag off, the app behaves exactly as the
|
||||||
# self-hosted BYOK app does today (no extra dependencies required).
|
# self-hosted BYOK app does today (no extra dependencies required).
|
||||||
BILLING_ENABLED = os.environ.get("BILLING_ENABLED", "").lower() in ("1", "true", "yes")
|
BILLING_ENABLED = os.environ.get("BILLING_ENABLED", "").lower() in ("1", "true", "yes")
|
||||||
|
|
||||||
|
# Job/file retention (issue #46). Self-host defaults to 24h: the 1h sweep kept
|
||||||
|
# deleting finished projects under users who never touched their env, and the
|
||||||
|
# OUTPUT_MAX_GB / UPLOADS_MAX_GB caps below already bound the disk. Cloud keeps
|
||||||
|
# the tight default because clips are archived to R2 as soon as a job finishes.
|
||||||
|
JOB_RETENTION_SECONDS = int(
|
||||||
|
os.environ.get("JOB_RETENTION_SECONDS", "3600" if BILLING_ENABLED else "86400")
|
||||||
|
)
|
||||||
# Force full pipeline logs to the client even under billing (local debugging).
|
# Force full pipeline logs to the client even under billing (local debugging).
|
||||||
DEBUG_LOGS = os.environ.get("DEBUG_LOGS", "").lower() in ("1", "true", "yes")
|
DEBUG_LOGS = os.environ.get("DEBUG_LOGS", "").lower() in ("1", "true", "yes")
|
||||||
|
|
||||||
|
|
@ -1391,6 +1398,7 @@ async def get_config():
|
||||||
"youtubeUrlEnabled": not DISABLE_YOUTUBE_URL,
|
"youtubeUrlEnabled": not DISABLE_YOUTUBE_URL,
|
||||||
"billingEnabled": BILLING_ENABLED,
|
"billingEnabled": BILLING_ENABLED,
|
||||||
"googleAuthEnabled": bool(BILLING_ENABLED and cloud.settings.google_auth_enabled),
|
"googleAuthEnabled": bool(BILLING_ENABLED and cloud.settings.google_auth_enabled),
|
||||||
|
"jobRetentionSeconds": JOB_RETENTION_SECONDS,
|
||||||
}
|
}
|
||||||
|
|
||||||
async def _probe_youtube_quality(url: str) -> dict:
|
async def _probe_youtube_quality(url: str) -> dict:
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,12 @@ const TikTokIcon = ({ size = 16, className = "" }) => (
|
||||||
// meaningless to the user, so the selector shows connected networks instead.
|
// meaningless to the user, so the selector shows connected networks instead.
|
||||||
const isAutoProfileId = (username) => /^os_[0-9a-f]/i.test(username || "");
|
const isAutoProfileId = (username) => /^os_[0-9a-f]/i.test(username || "");
|
||||||
|
|
||||||
|
const formatRetention = (seconds) => {
|
||||||
|
if (seconds >= 86400) return `${Math.round(seconds / 86400)} day${seconds >= 172800 ? 's' : ''}`;
|
||||||
|
if (seconds >= 3600) return `${Math.round(seconds / 3600)} hour${seconds >= 7200 ? 's' : ''}`;
|
||||||
|
return `${Math.max(1, Math.round(seconds / 60))} min`;
|
||||||
|
};
|
||||||
|
|
||||||
const ProfileNetworkIcons = ({ profile, size = 12 }) => (
|
const ProfileNetworkIcons = ({ profile, size = 12 }) => (
|
||||||
<span className="flex items-center gap-1.5">
|
<span className="flex items-center gap-1.5">
|
||||||
<span className={profile?.connected?.includes('tiktok') ? 'text-ink' : 'text-muted opacity-40'}>
|
<span className={profile?.connected?.includes('tiktok') ? 'text-ink' : 'text-muted opacity-40'}>
|
||||||
|
|
@ -163,7 +169,9 @@ const UserProfileSelector = ({ profiles, selectedUserId, onSelect }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const SESSION_KEY = 'openshorts_session';
|
const SESSION_KEY = 'openshorts_session';
|
||||||
const SESSION_MAX_AGE = 3600000; // 1 hour (matches server job retention)
|
// Matches the self-host JOB_RETENTION_SECONDS default. A restore whose job was
|
||||||
|
// already purged server-side fails gracefully and clears the saved session.
|
||||||
|
const SESSION_MAX_AGE = 86400000; // 24 hours
|
||||||
|
|
||||||
// Mock polling function
|
// Mock polling function
|
||||||
const pollJob = async (jobId) => {
|
const pollJob = async (jobId) => {
|
||||||
|
|
@ -174,7 +182,7 @@ const pollJob = async (jobId) => {
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
// Cloud auth/billing session (inert when billing is disabled).
|
// Cloud auth/billing session (inert when billing is disabled).
|
||||||
const { billingEnabled, isManaged, isSignedIn, me, plan, refreshMe } = useAuth();
|
const { billingEnabled, isManaged, isSignedIn, me, plan, refreshMe, jobRetentionSeconds } = useAuth();
|
||||||
const [showLogin, setShowLogin] = useState(false);
|
const [showLogin, setShowLogin] = useState(false);
|
||||||
const [showTopUp, setShowTopUp] = useState(false);
|
const [showTopUp, setShowTopUp] = useState(false);
|
||||||
const [showPlanChoice, setShowPlanChoice] = useState(false);
|
const [showPlanChoice, setShowPlanChoice] = useState(false);
|
||||||
|
|
@ -1451,6 +1459,14 @@ function App() {
|
||||||
<span className="text-brass font-medium">Keep them forever →</span>
|
<span className="text-brass font-medium">Keep them forever →</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
{/* Self-host only: cloud archives clips to the video library,
|
||||||
|
here they really are gone once the retention sweep runs. */}
|
||||||
|
{!billingEnabled && jobRetentionSeconds > 0 && (
|
||||||
|
<div className="px-3 py-2.5 rounded-input bg-paper3 border border-paper3 text-sm">
|
||||||
|
<span className="text-ink">Clips are kept for {formatRetention(jobRetentionSeconds)}, then deleted.</span>{' '}
|
||||||
|
<span className="text-muted">Download what you want to keep, or raise JOB_RETENTION_SECONDS in your env.</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<StarBanner message="Happy with your clips?" />
|
<StarBanner message="Happy with your clips?" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ export function AuthProvider({ children }) {
|
||||||
const value = {
|
const value = {
|
||||||
billingEnabled: config.billingEnabled,
|
billingEnabled: config.billingEnabled,
|
||||||
googleAuthEnabled: config.googleAuthEnabled,
|
googleAuthEnabled: config.googleAuthEnabled,
|
||||||
|
jobRetentionSeconds: config.jobRetentionSeconds || null,
|
||||||
loading,
|
loading,
|
||||||
signingIn,
|
signingIn,
|
||||||
user: me?.user || null,
|
user: me?.user || null,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue