From 0249a72caba9f1a4eeaf51f382a74fe61b66c284 Mon Sep 17 00:00:00 2001
From: Georg Ehrke <dev@georgswebsite.de>
Date: Thu, 26 Apr 2012 17:35:12 +0200
Subject: [PATCH] fix downloading of files in files app

---
 apps/files/js/fileactions.js | 2 +-
 apps/files/js/files.js       | 6 +++---
 core/js/js.js                | 5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 80e918a455..fc6c99262e 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -135,7 +135,7 @@ $(document).ready(function(){
 		var downloadScope = 'file';
 	}
 	FileActions.register(downloadScope,'Download',function(){return OC.imagePath('core','actions/download')},function(filename){
-		window.location='ajax/download.php?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val());
+		window.location=OC.filePath('files', 'ajax', 'download.php?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val()));
 	});
 });
 
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 3ce95f992d..4637d3cb64 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -140,7 +140,7 @@ $(document).ready(function() {
 		var dir=$('#dir').val()||'/';
 		$('#notification').text(t('files','generating ZIP-file, it may take some time.'));
 		$('#notification').fadeIn();
-		window.location='ajax/download.php?files='+encodeURIComponent(files)+'&dir='+encodeURIComponent(dir);
+		window.location=OC.filePath('files', 'ajax', 'download.php?files='+encodeURIComponent(files)+'&dir='+encodeURIComponent(dir));
 		return false;
 	});
 
@@ -418,7 +418,7 @@ var folderDropOptions={
 		var target=$(this).text().trim();
 		var dir=$('#dir').val();
 		$.ajax({
-			url: 'ajax/move.php',
+			url: OC.filePath('files', 'ajax', 'move.php'),
 		data: "dir="+encodeURIComponent(dir)+"&file="+encodeURIComponent(file)+'&target='+encodeURIComponent(dir)+'/'+encodeURIComponent(target),
 		complete: function(data){boolOperationFinished(data, function(){
 			var el = $('#fileList tr').filterAttr('data-file',file).find('td.filename');
@@ -444,7 +444,7 @@ var crumbDropOptions={
 			return;
 		}
 		$.ajax({
-			url: 'ajax/move.php',
+			url: OC.filePath('files', 'ajax', 'move.php'),
 		 data: "dir="+encodeURIComponent(dir)+"&file="+encodeURIComponent(file)+'&target='+encodeURIComponent(target),
 		 complete: function(data){boolOperationFinished(data, function(){
 			 FileList.remove(file);
diff --git a/core/js/js.js b/core/js/js.js
index 12303d7dd9..84875ca162 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -53,12 +53,13 @@ OC={
 	filePath:function(app,type,file){
 		var isCore=OC.coreApps.indexOf(app)!=-1;
 		var link=OC.webroot;
-		if((file.substring(file.length-3) == 'php' || file.substring(file.length-3) == 'css') && !isCore){
+		var splitted = file.split('?');
+		if((splitted[0].substring(splitted[0].length-3) == 'php' || splitted[0].substring(splitted[0].length-3) == 'css') && !isCore){
 			link+='/?app=' + app + '&getfile=';
 			if(type){
 				link+=encodeURI(type + '/');
 			}
-			link+= file;
+			link+= file + '?' + splitted[1];
 		}else if(file.substring(file.length-3) != 'php' && !isCore){
 			link=OC.appswebroot;
 			link+='/';
-- 
GitLab