]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge branch 'master' into fix_3728_with_file_exists_dialog
authorJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 19 Sep 2013 15:00:54 +0000 (17:00 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 19 Sep 2013 15:00:54 +0000 (17:00 +0200)
Conflicts:
apps/files/js/filelist.js

1  2 
apps/files/ajax/upload.php
apps/files/css/files.css
apps/files/js/fileactions.js
apps/files/js/filelist.js
apps/files/js/files.js

index 12724c0c5bc157576c41a8bdfd9c5c0342b9b26c,41d3a3eca4fe574577bcb496ced8f003b5fb1dfc..3d5314afc89d0209230b11a4728055945551c70a
@@@ -98,58 -98,26 +98,60 @@@ $result = array()
  if (strpos($dir, '..') === false) {
        $fileCount = count($files['name']);
        for ($i = 0; $i < $fileCount; $i++) {
 -              $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
                // $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
 -              $target = \OC\Files\Filesystem::normalizePath($target);
 -              if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
 +              if (isset($_POST['resolution']) && $_POST['resolution']==='autorename') {
 +                      // append a number in brackets like 'filename (2).ext'
 +                      $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
 +              } else {
 +                      $target = \OC\Files\Filesystem::normalizePath(stripslashes($dir).'/'.$files['name'][$i]);
 +              }
 +              
 +              if ( ! \OC\Files\Filesystem::file_exists($target)
 +                      || (isset($_POST['resolution']) && $_POST['resolution']==='replace')
 +              ) {
 +                      // upload and overwrite file
 +                      if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
 +                              
 +                              // updated max file size after upload
 +                              $storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
 +                              
 +                              $meta = \OC\Files\Filesystem::getFileInfo($target);
 +                              if ($meta === false) {
 +                                      $error = $l->t('Upload failed. Could not get file info.');
 +                              } else {
 +                                      $result[] = array('status' => 'success',
 +                                              'mime' => $meta['mimetype'],
 +                                              'mtime' => $meta['mtime'],
 +                                              'size' => $meta['size'],
 +                                              'id' => $meta['fileid'],
 +                                              'name' => basename($target),
 +                                              'originalname' => $files['tmp_name'][$i],
 +                                              'uploadMaxFilesize' => $maxUploadFileSize,
-                                               'maxHumanFilesize' => $maxHumanFileSize
++                                              'maxHumanFilesize' => $maxHumanFileSize,
++                                              'permissions' => $meta['permissions'],
 +                                      );
 +                              }
 +                              
 +                      } else {
 +                              $error = $l->t('Upload failed. Could not find uploaded file');
 +                      }
 +                      
 +              } else {
 +                      // file already exists
                        $meta = \OC\Files\Filesystem::getFileInfo($target);
 -                      // updated max file size after upload
 -                      $storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
                        if ($meta === false) {
 -                              OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Upload failed')), $storageStats)));
 -                              exit();
 +                              $error = $l->t('Upload failed. Could not get file info.');
                        } else {
 -                              $result[] = array('status' => 'success',
 +                              $result[] = array('status' => 'existserror',
                                        'mime' => $meta['mimetype'],
 +                                      'mtime' => $meta['mtime'],
                                        'size' => $meta['size'],
                                        'id' => $meta['fileid'],
                                        'name' => basename($target),
 -                                      'originalname' => $files['name'][$i],
 +                                      'originalname' => $files['tmp_name'][$i],
                                        'uploadMaxFilesize' => $maxUploadFileSize,
-                                       'maxHumanFilesize' => $maxHumanFileSize
+                                       'maxHumanFilesize' => $maxHumanFileSize,
+                                       'permissions' => $meta['permissions'],
                                );
                        }
                }
Simple merge
Simple merge
index 39df91c94b400ddaf81c30589242b487a56bb29b,fe706801b9e2699a562607fab729b576e24488b6..4fc1b95a0ab5612bc48560b2328589cc83ab3179
@@@ -762,21 -744,11 +792,28 @@@ $(document).ready(function()
                                var date=new Date();
                                var param = {};
                                if ($('#publicUploadRequestToken').length) {
 -                                      param.download_url = document.location.href + '&download&path=/' + $('#dir').val() + '/' + uniqueName;
 +                                      param.download_url = document.location.href + '&download&path=/' + $('#dir').val() + '/' + file.name;
                                }
 +                              //should the file exist in the list remove it
 +                              FileList.remove(file.name);
 +
                                // create new file context
 -                              data.context = FileList.addFile(uniqueName,size,date,true,false,param);
 +                              data.context = FileList.addFile(file.name, file.size, date, false, false, param);
 +
 +                              // update file data
 +                              data.context.attr('data-mime',file.mime).attr('data-id',file.id);
 +
++                              var permissions = data.context.data('permissions');
++                              if(permissions != file.permissions) {
++                                      data.context.attr('data-permissions', file.permissions);
++                                      data.context.data('permissions', file.permissions);
++                              }
++                              FileActions.display(data.context.find('td.filename'));
 +                              var path = getPathForPreview(file.name);
 +                              lazyLoadPreview(path, file.mime, function(previewpath){
 +                                      data.context.find('td.filename').attr('style','background-image:url('+previewpath+')');
 +                              });
                        }
                }
        });
Simple merge