From 524e3686a0da79493a6048d8d92b7bbb0982ec08 Mon Sep 17 00:00:00 2001
From: Robin Appelman
Date: Thu, 10 Nov 2011 16:40:09 +0100
Subject: [PATCH] tell the user when the files are being scanned
---
apps/files_sharing/sharedstorage.php | 29 ++++++---------------------
files/ajax/scan.php | 16 +++++++++++++++
files/css/files.css | 4 +++-
files/js/files.js | 19 ++++++++++++++++++
files/templates/index.php | 5 +++++
lib/filecache.php | 2 ++
lib/util.php | 5 -----
owncloud.db.filesystem | Bin 0 -> 2348032 bytes
8 files changed, 51 insertions(+), 29 deletions(-)
create mode 100644 files/ajax/scan.php
create mode 100644 owncloud.db.filesystem
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 5e5360e899..f7849d499f 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -172,18 +172,9 @@ class OC_Filestorage_Shared extends OC_Filestorage {
// TODO fill in other components of array
public function stat($path) {
if ($path == "" || $path == "/") {
- $stat["dev"] = "";
- $stat["ino"] = "";
- $stat["mode"] = "";
- $stat["nlink"] = "";
- $stat["uid"] = "";
- $stat["gid"] = "";
- $stat["rdev"] = "";
$stat["size"] = $this->filesize($path);
$stat["mtime"] = $this->filemtime($path);
$stat["ctime"] = $this->filectime($path);
- $stat["blksize"] = "";
- $stat["blocks"] = "";
return $stat;
} else {
$source = $this->getSource($path);
@@ -220,18 +211,7 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
public function getFolderSize($path) {
- // Shared folder sizes are cached separately from the source folder sizes because folders can have different names
- $path = rtrim($path, "/");
- $path = ltrim($path, "/");
- $path = preg_replace('{(/)\1+}', "/", $path);
- $dbpath = rtrim($this->datadir.$path, "/");
-// $query = OC_DB::prepare("SELECT size FROM *PREFIX*foldersize WHERE path = ?");
-// $size = $query->execute(array($dbpath))->fetchAll();
- if (count($size) > 0) {
- return $size[0]['size'];
- } else {
- return $this->calculateFolderSize($path);
- }
+ return 0; //depricated
}
private function calculateFolderSize($path) {
@@ -321,8 +301,8 @@ class OC_Filestorage_Shared extends OC_Filestorage {
$ctime = $tempctime;
}
}
- return $ctime;
}
+ return $ctime;
} else {
$source = $this->getSource($path);
if ($source) {
@@ -342,8 +322,8 @@ class OC_Filestorage_Shared extends OC_Filestorage {
$mtime = $tempmtime;
}
}
- return $mtime;
}
+ return $mtime;
} else {
$source = $this->getSource($path);
if ($source) {
@@ -482,6 +462,9 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
public function getMimeType($path) {
+ if ($path2 == "" || $path2 == "/") {
+ return 'httpd/unix-directory';
+ }
$source = $this->getSource($path);
if ($source) {
$storage = OC_Filesystem::getStorage($source);
diff --git a/files/ajax/scan.php b/files/ajax/scan.php
new file mode 100644
index 0000000000..dec949a819
--- /dev/null
+++ b/files/ajax/scan.php
@@ -0,0 +1,16 @@
+ array( "done" => true)));
+}else{
+ OC_JSON::success(array("data" => array( "done" => false)));
+}
\ No newline at end of file
diff --git a/files/css/files.css b/files/css/files.css
index 22f4810d0a..39f0b9fe78 100644
--- a/files/css/files.css
+++ b/files/css/files.css
@@ -73,4 +73,6 @@ table thead.fixed { height:2em; }
/* add breadcrumb divider to the File item in navigation panel */
#navigation>ul>li:first-child { background:url('../../core/img/breadcrumb-start.svg') no-repeat 12.5em 0px; width:12.5em; padding-right:1em; position:fixed; }
-#navigation>ul>li:first-child+li { padding-top:2.9em; }
\ No newline at end of file
+#navigation>ul>li:first-child+li { padding-top:2.9em; }
+
+#scanning-message{ top:40%; left:40%; position:absolute; display:none }
\ No newline at end of file
diff --git a/files/js/files.js b/files/js/files.js
index 4eaa098241..4dca1a110e 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -334,8 +334,27 @@ $(document).ready(function() {
$('#new>a').click();
});
});
+
+ //check if we need to scan the filesystem
+ $.get(OC.filePath('files','ajax','scan.php'),{checkonly:'true'}, function(response) {
+ if(response.data.done){
+ scanFiles();
+ }
+ }, "json");
});
+function scanFiles(force){
+ force=!!force; //cast to bool
+ $('#scanning-message').show();
+ $.get(OC.filePath('files','ajax','scan.php'), function(response) {
+ if(response && response.data && response.data.done){
+ window.location.reload();
+ }else{
+ alert('error')
+ }
+ }, "json");
+}
+
function boolOperationFinished(data, callback) {
result = jQuery.parseJSON(data.responseText);
if(result.status == 'success'){
diff --git a/files/templates/index.php b/files/templates/index.php
index 722c38e477..21a4e2df01 100644
--- a/files/templates/index.php
+++ b/files/templates/index.php
@@ -63,3 +63,8 @@ if (isset($_['files'])) {
t('The files you are trying to upload exceed the maximum size for file uploads on this server.');?>
+
+
+ t('Files are being scanned, please wait.');?>
+
+
diff --git a/lib/filecache.php b/lib/filecache.php
index 41e31b5de2..902a8052af 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -70,6 +70,8 @@ class OC_FileCache{
}
$mimePart=dirname($data['mimetype']);
$query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart) VALUES(?,?,?,?,?,?,?,?)');
+// echo $path;
+// print_r($data);
$query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart));
}
diff --git a/lib/util.php b/lib/util.php
index b20e8e69e7..e010a572e3 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -49,11 +49,6 @@ class OC_Util {
$quotaProxy=new OC_FileProxy_Quota();
OC_FileProxy::register($quotaProxy);
self::$fsSetup=true;
-
- //create the file cache if necesary
- if(!OC_FileCache::inCache('')){
- OC_FileCache::scan('');
- }
}
}
diff --git a/owncloud.db.filesystem b/owncloud.db.filesystem
new file mode 100644
index 0000000000000000000000000000000000000000..082977a37eff00bc5a0e6aeffa6a8fa9f57025fd
GIT binary patch
literal 2348032
zcmeEv31C#k{r}8+8$!YjLV%F)5D_ATO@MHCRC5smNr)tXh#FsZUy>zzggppB6c>+L
zt+raNw)Lph+QVwodemP}tw+_?YJc|dXFYnWwN?A8J^j`GKi`?R*V}!Y7pwiZb_2V!
zZ{Ey&XTEcN=X*`p$!)%