@@ -33,7 +33,6 @@ function updateMetaField(uuid, namespace, value) {
3333 } ;
3434
3535 Curate . api . fetchCurate ( url , "PUT" , metadatas ) ;
36- console . log ( `Attempted to update metadata '${ namespace } ' for UUID ${ uuid } ` ) ;
3736}
3837
3938function fetchCurateStats ( filePath , expectedChecksum , retryCount ) {
@@ -107,7 +106,6 @@ let workerManager = null;
107106async function generateChecksum ( uploadItem ) {
108107 if ( ! workerManager ) {
109108 workerManager = new ChecksumWorkerManager ( ) ;
110- console . log ( "ChecksumWorkerManager initialized" ) ;
111109 }
112110
113111 const multipartDecisionThreshold = PydioApi . getMultipartThreshold ( ) ;
@@ -119,10 +117,6 @@ async function generateChecksum(uploadItem) {
119117 // Calculate checksum: use multipart calculation for large files, single MD5 for smaller ones.
120118 if ( uploadItem . _file . size > multipartDecisionThreshold ) {
121119 // Multipart checksum logic:
122- console . log (
123- "File exceeds multipart threshold, generating part checksums for:" ,
124- uploadItem . _label
125- ) ;
126120 const partSize = multipartPartSize ;
127121 const parts = Math . ceil ( uploadItem . _file . size / partSize ) ;
128122 const partChecksumsHex = [ ] ; // Store hex for potential debugging
@@ -153,10 +147,6 @@ async function generateChecksum(uploadItem) {
153147 ) ;
154148 } else {
155149 // Single part checksum calculation for smaller files.
156- console . log (
157- "File below multipart threshold, generating single checksum for:" ,
158- uploadItem . _label
159- ) ;
160150 const checksumData = await workerManager . generateChecksum ( uploadItem . _file ) ;
161151 finalChecksum = checksumData . hash ;
162152 console . log ( "Generated single checksum:" , finalChecksum ) ;
@@ -175,50 +165,68 @@ async function generateChecksum(uploadItem) {
175165}
176166
177167function constructFilePath ( uploadItem ) {
178- // This logic determines the correct path to query for stats, accounting for
179- // potential server-side renaming on filename collision (e.g., file.txt -> file-1.txt).
168+ console . log ( "constructing file path for item: " , uploadItem ) ;
169+
170+ // Extract the file path from the presigned URL responseURL.
171+ // This is the source of truth for where the file was actually uploaded.
172+ const responseURL = uploadItem . xhr ?. responseURL ;
173+
174+ if ( responseURL ) {
175+ try {
176+ // Parse the URL to extract the path between /io/ and the query parameters
177+ const url = new URL ( responseURL ) ;
178+ const pathname = url . pathname ;
179+
180+ // Extract everything after /io/
181+ const ioIndex = pathname . indexOf ( '/io/' ) ;
182+ if ( ioIndex !== - 1 ) {
183+ const pathAfterIo = pathname . substring ( ioIndex + 4 ) ; // +4 to skip '/io/'
184+ // Decode URI components to handle encoded characters
185+ const decodedPath = decodeURIComponent ( pathAfterIo ) ;
186+ console . log ( "Extracted path from responseURL:" , decodedPath ) ;
187+ return decodedPath ;
188+ }
189+ } catch ( error ) {
190+ console . error ( "Failed to parse responseURL:" , error ) ;
191+ // Fall through to legacy path construction
192+ }
193+ }
194+
195+ // Fallback to legacy path construction if responseURL is unavailable
196+ console . warn ( "responseURL not available, using legacy path construction" ) ;
180197 const workspace = Curate . workspaces . getOpenWorkspace ( ) ;
181- const targetPath = uploadItem . _targetNode . _path ; // Path of the destination folder.
182- const relativeFilePath = uploadItem . _file . webkitRelativePath ; // Original path *within* an uploaded folder structure, or "" for single files.
183- const finalLabel = uploadItem . _label ; // This property is updated by the UploaderModel to reflect the FINAL filename after potential renaming.
198+ const targetPath = uploadItem . _targetNode . _path ;
199+ const relativeFilePath = uploadItem . _file . webkitRelativePath ;
200+ const finalLabel = uploadItem . _label ;
184201
185- // Normalize workspace and target paths to ensure correct slash handling.
186202 const normWorkspace = workspace . endsWith ( "/" ) ? workspace : workspace + "/" ;
187203 let normTarget = "" ;
188204 if ( targetPath && targetPath !== "/" ) {
189- // Handle root path '/'
190- normTarget = targetPath . replace ( / ^ \/ + | \/ + $ / g, "" ) ; // Remove leading/trailing slashes
205+ normTarget = targetPath . replace ( / ^ \/ + | \/ + $ / g, "" ) ;
191206 }
192207
193208 let fileComponent = "" ;
194- // Check if a folder structure was uploaded (relativeFilePath is not empty).
195209 if ( relativeFilePath ) {
196- // Combine the original directory structure from relativeFilePath with the FINAL filename from finalLabel.
197210 const lastSlashIndex = relativeFilePath . lastIndexOf ( "/" ) ;
198211 if ( lastSlashIndex !== - 1 ) {
199- // Extract the directory part (e.g., "folder/subfolder/")
200212 const dirPart = relativeFilePath . substring ( 0 , lastSlashIndex + 1 ) ;
201- fileComponent = dirPart + finalLabel ; // Append the final filename
213+ fileComponent = dirPart + finalLabel ;
202214 } else {
203- // Relative path contained only the original filename, so just use the final label.
204215 fileComponent = finalLabel ;
205216 }
206- // Ensure no leading slash inherited from relativeFilePath.
207217 if ( fileComponent . startsWith ( "/" ) ) {
208218 fileComponent = fileComponent . substring ( 1 ) ;
209219 }
210220 } else {
211- // Single file upload, use the final label directly as the file component.
212221 fileComponent = finalLabel ;
213222 }
214223
215- // Combine all parts into the final path.
216224 let filename = normWorkspace ;
217225 if ( normTarget ) {
218- filename += normTarget + "/" ; // Add normalized target path if not root
226+ filename += normTarget + "/" ;
219227 }
220- filename += fileComponent ; // Add the final file/path component
221- filename = filename . replace ( / \/ + / g, "/" ) ; // Clean up any resulting double slashes.
228+ filename += fileComponent ;
229+ filename = filename . replace ( / \/ + / g, "/" ) ;
222230
223231 return filename ;
224232}
@@ -229,7 +237,6 @@ export default {
229237
230238 hooks : {
231239 onUploadComplete : async ( uploadItem ) => {
232- console . log ( 'ChecksumValidation: Processing upload completion for:' , uploadItem . _label ) ;
233240
234241 try {
235242 // Generate checksum for the uploaded file
0 commit comments