[Pkg-owncloud-commits] [owncloud] 218/239: Update file list entry on rename

David Prévot taffit at moszumanska.debian.org
Fri Nov 29 01:32:41 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 68f610a90e496f95bec54dd97e992a01e34c61bc
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Wed Nov 27 21:34:19 2013 +0100

    Update file list entry on rename
    
    Whenever a file is renamed, if the extension changes, the mime type and
    preview might change. This fix passes the updated info to the client
    that updates it.
---
 apps/files/js/filelist.js | 19 +++++++++++++++++--
 apps/files/lib/app.php    | 17 ++++++++++++-----
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 6645374..b8ae00a 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -422,12 +422,27 @@ var FileList={
 								}
 								tr.find('.fileactions').effect('highlight', {}, 5000);
 								tr.effect('highlight', {}, 5000);
+								// remove loading mark and recover old image
+								td.css('background-image', oldBackgroundImage);
+							}
+							else {
+								var fileInfo = result.data;
+								tr.attr('data-mime', fileInfo.mime);
+								tr.attr('data-etag', fileInfo.etag);
+								if (fileInfo.isPreviewAvailable) {
+									Files.lazyLoadPreview(fileInfo.directory + '/' + fileInfo.name, result.data.mime, function(previewpath) {
+										tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
+									}, null, null, result.data.etag);
+								}
+								else {
+									tr.find('td.filename').removeClass('preview').attr('style','background-image:url('+fileInfo.icon+')');
+								}
 							}
 							// reinsert row
 							tr.detach();
 							FileList.insertElement( tr.attr('data-file'), tr.attr('data-type'),tr );
-							// remove loading mark and recover old image
-							td.css('background-image', oldBackgroundImage);
+							// update file actions in case the extension changed
+							FileActions.display( tr.find('td.filename'), true);
 						}
 					});
 				}
diff --git a/apps/files/lib/app.php b/apps/files/lib/app.php
index f5ac11b..ea94ea4 100644
--- a/apps/files/lib/app.php
+++ b/apps/files/lib/app.php
@@ -76,12 +76,19 @@ class App {
 			$this->view->rename($dir . '/' . $oldname, $dir . '/' . $newname)
 		) {
 			// successful rename
-			$result['success'] = true;
-			$result['data'] = array(
-				'dir'		=> $dir,
-				'file'		=> $oldname,
-				'newname'	=> $newname
+			$meta = $this->view->getFileInfo($dir . '/' . $newname);
+			$fileinfo = array(
+				'id' => $meta['fileid'],
+				'mime' => $meta['mimetype'],
+				'size' => $meta['size'],
+				'etag' => $meta['etag'],
+				'directory' => $dir,
+				'name' => $newname,
+				'isPreviewAvailable' => \OC::$server->getPreviewManager()->isMimeSupported($meta['mimetype']),
+				'icon' => \OCA\Files\Helper::determineIcon($meta)
 			);
+			$result['success'] = true;
+			$result['data'] = $fileinfo;
 		} else {
 			// rename failed
 			$result['data'] = array(

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list