@ -1649,15 +1649,34 @@
data . context . find ( 'td.filesize' ) . text ( humanFileSize ( size ) ) ;
} else {
// only append new file if uploaded into the current folder
if ( file . directory !== '/' && file . directory !== self . getCurrentDirectory ( ) ) {
if ( file . directory !== self . getCurrentDirectory ( ) ) {
// Uploading folders actually uploads a list of files
// for which the target directory (file.directory) might lie deeper
// than the current directory
var fileDirectory = file . directory . replace ( '/' , '' ) . replace ( /\/$/ , "" ) ;
var currentDirectory = self . getCurrentDirectory ( ) . replace ( '/' , '' ) . replace ( /\/$/ , "" ) + '/' ;
if ( currentDirectory !== '/' ) {
// abort if fileDirectory does not start with current one
if ( fileDirectory . indexOf ( currentDirectory ) !== 0 ) {
return ;
}
// remove the current directory part
fileDirectory = fileDirectory . substr ( currentDirectory . length ) ;
}
var fileDirectory = file . directory . replace ( '/' , '' ) . replace ( /\/$/ , "" ) . split ( '/' ) ;
// only take the first section of the path
fileDirectory = fileDirectory . split ( '/' ) ;
if ( fileDirectory . length === 1 ) {
var fd ;
// if the first section exists / is a subdir
if ( fileDirectory . length ) {
fileDirectory = fileDirectory [ 0 ] ;
// Get the directory
var fd = self . findFileEl ( fileDirectory ) ;
// See whether it is already in the list
fd = self . findFileEl ( fileDirectory ) ;
if ( fd . length === 0 ) {
var dir = {
name : fileDirectory ,
@ -1667,19 +1686,15 @@
size : 0 ,
id : file . parentId
} ;
self . add ( dir , { insert : true } ) ;
fd = self . add ( dir , { insert : true } ) ;
}
} else {
fileDirectory = fileDirectory [ 0 ] ;
}
fileDirectory = self . findFileEl ( fileDirectory ) ;
// update folder size
size = parseInt ( fileDirectory . attr ( 'data-size' ) , 10 ) ;
size += parseInt ( file . size , 10 ) ;
fileDirectory . attr ( 'data-size' , size ) ;
fileDirectory . find ( 'td.filesize' ) . text ( humanFileSize ( size ) ) ;
// update folder size
size = parseInt ( fd . attr ( 'data-size' ) , 10 ) ;
size += parseInt ( file . size , 10 ) ;
fd . attr ( 'data-size' , size ) ;
fd . find ( 'td.filesize' ) . text ( OC . Util . humanFileSize ( size ) ) ;
}
return ;
}