Remove uploads and logs from git tracking
User-uploaded content and log files should not be version controlled: - Added uploads/ and *.log to .gitignore - Removed uploads/ directory from tracking (files remain on disk) - Removed api/menu/saveFromBuilder.log from tracking This prevents git reset --hard from overwriting user content during deploys. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c75352d32a
commit
fc27e2b87f
4 changed files with 45 additions and 6758 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -4,7 +4,10 @@ config/claude.json
|
|||
# Temp files
|
||||
*.tmp
|
||||
*.bak
|
||||
*.log
|
||||
|
||||
# User uploads (never version control user content)
|
||||
uploads/
|
||||
|
||||
# One-off admin/debug scripts (not deployed)
|
||||
api/admin/_scripts/
|
||||
uploads/
|
||||
|
|
|
|||
|
|
@ -529,12 +529,13 @@
|
|||
</cfloop>
|
||||
</cfif>
|
||||
|
||||
<!--- Get brand color and tax rate for this business --->
|
||||
<!--- Get brand color, tax rate, and header image for this business --->
|
||||
<cfset brandColor = "">
|
||||
<cfset businessTaxRate = 0>
|
||||
<cfset headerImageUrl = "">
|
||||
<cftry>
|
||||
<cfset qBrand = queryTimed(
|
||||
"SELECT BrandColor AS BusinessBrandColor, TaxRate FROM Businesses WHERE ID = ?",
|
||||
"SELECT BrandColor AS BusinessBrandColor, TaxRate, HeaderImageExtension FROM Businesses WHERE ID = ?",
|
||||
[ { value = BusinessID, cfsqltype = "cf_sql_integer" } ],
|
||||
{ datasource = "payfrit" }
|
||||
)>
|
||||
|
|
@ -545,6 +546,9 @@
|
|||
<cfif isNumeric(qBrand.TaxRate)>
|
||||
<cfset businessTaxRate = qBrand.TaxRate>
|
||||
</cfif>
|
||||
<cfif len(trim(qBrand.HeaderImageExtension))>
|
||||
<cfset headerImageUrl = "/uploads/headers/#BusinessID#.#qBrand.HeaderImageExtension#">
|
||||
</cfif>
|
||||
</cfif>
|
||||
<cfcatch>
|
||||
<!--- Column may not exist yet, ignore --->
|
||||
|
|
@ -558,6 +562,7 @@
|
|||
"COUNT": arrayLen(rows),
|
||||
"SCHEMA": newSchemaActive ? "unified" : "legacy",
|
||||
"BRANDCOLOR": brandColor,
|
||||
"HEADERIMAGEURL": headerImageUrl,
|
||||
"TAXRATE": val(businessTaxRate),
|
||||
"Menus": menuList,
|
||||
"SelectedMenuID": requestedMenuID
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -34,17 +34,44 @@ if (bizId LTE 0) {
|
|||
<!--- Upload the file to temp location first --->
|
||||
<cffile action="UPLOAD" filefield="header" destination="#headersDir#/" nameconflict="MAKEUNIQUE" mode="755" result="uploadResult">
|
||||
|
||||
<!--- Get image info and detect actual format --->
|
||||
<cfimage source="#headersDir#/#uploadResult.ServerFile#" action="info" structName="imageInfo">
|
||||
|
||||
<!--- Use the actual detected format, not the client-provided extension --->
|
||||
<cfset actualFormat = lCase(imageInfo.source_file)>
|
||||
<cfset actualExt = "">
|
||||
<cfif findNoCase("jpeg", actualFormat) OR findNoCase("jpg", actualFormat)>
|
||||
<cfset actualExt = "jpg">
|
||||
<cfelseif findNoCase("png", actualFormat)>
|
||||
<cfset actualExt = "png">
|
||||
<cfelseif findNoCase("gif", actualFormat)>
|
||||
<cfset actualExt = "gif">
|
||||
<cfelseif findNoCase("webp", actualFormat)>
|
||||
<cfset actualExt = "webp">
|
||||
<cfelse>
|
||||
<!--- Fallback: detect by reading first bytes (magic numbers) --->
|
||||
<cffile action="readbinary" file="#headersDir#/#uploadResult.ServerFile#" variable="fileBytes">
|
||||
<cfset firstBytes = left(binaryEncode(fileBytes, "hex"), 16)>
|
||||
<cfif left(firstBytes, 4) EQ "FFD8">
|
||||
<cfset actualExt = "jpg">
|
||||
<cfelseif left(firstBytes, 16) EQ "89504E470D0A1A0A">
|
||||
<cfset actualExt = "png">
|
||||
<cfelseif left(firstBytes, 6) EQ "474946">
|
||||
<cfset actualExt = "gif">
|
||||
<cfelse>
|
||||
<!--- Last resort: use client extension --->
|
||||
<cfset actualExt = lCase(uploadResult.ClientFileExt)>
|
||||
</cfif>
|
||||
</cfif>
|
||||
|
||||
<!--- Validate file type --->
|
||||
<cfset allowedExtensions = "jpg,jpeg,gif,png,webp">
|
||||
<cfif NOT listFindNoCase(allowedExtensions, uploadResult.ClientFileExt)>
|
||||
<cfif NOT listFindNoCase(allowedExtensions, actualExt)>
|
||||
<cffile action="DELETE" file="#headersDir#/#uploadResult.ServerFile#">
|
||||
<cfoutput>#serializeJSON({ "OK": false, "ERROR": "invalid_type", "MESSAGE": "Only image files are accepted (jpg, jpeg, gif, png, webp)" })#</cfoutput>
|
||||
<cfabort>
|
||||
</cfif>
|
||||
|
||||
<!--- Get image info --->
|
||||
<cfimage source="#headersDir#/#uploadResult.ServerFile#" action="info" structName="imageInfo">
|
||||
|
||||
<!--- No resize - accept image as-is --->
|
||||
|
||||
<!--- Delete old header if exists --->
|
||||
|
|
@ -65,7 +92,7 @@ if (bizId LTE 0) {
|
|||
</cfif>
|
||||
|
||||
<!--- Also delete destination file if it exists (same extension re-upload) --->
|
||||
<cfset destFile = "#headersDir#/#bizId#.#uploadResult.ClientFileExt#">
|
||||
<cfset destFile = "#headersDir#/#bizId#.#actualExt#">
|
||||
<cfif fileExists(destFile)>
|
||||
<cftry>
|
||||
<cffile action="DELETE" file="#destFile#">
|
||||
|
|
@ -79,7 +106,7 @@ if (bizId LTE 0) {
|
|||
<!--- Update database --->
|
||||
<cfquery datasource="payfrit">
|
||||
UPDATE Businesses
|
||||
SET HeaderImageExtension = <cfqueryparam cfsqltype="cf_sql_varchar" value="#uploadResult.ClientFileExt#">
|
||||
SET HeaderImageExtension = <cfqueryparam cfsqltype="cf_sql_varchar" value="#actualExt#">
|
||||
WHERE ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#bizId#">
|
||||
</cfquery>
|
||||
|
||||
|
|
@ -88,7 +115,7 @@ if (bizId LTE 0) {
|
|||
"OK": true,
|
||||
"ERROR": "",
|
||||
"MESSAGE": "Header uploaded successfully",
|
||||
"HEADERURL": "/uploads/headers/#bizId#.#uploadResult.ClientFileExt#",
|
||||
"HEADERURL": "/uploads/headers/#bizId#.#actualExt#",
|
||||
"WIDTH": imageInfo.width,
|
||||
"HEIGHT": imageInfo.height
|
||||
})#</cfoutput>
|
||||
|
|
|
|||
Reference in a new issue