summaryrefslogtreecommitdiffstats
path: root/files
diff options
context:
space:
mode:
Diffstat (limited to 'files')
-rw-r--r--files/ajax/scan.php31
-rw-r--r--files/ajax/upload.php2
-rw-r--r--files/css/files.css4
-rw-r--r--files/js/files.js29
-rw-r--r--files/templates/index.php8
-rw-r--r--files/templates/part.list.php4
6 files changed, 74 insertions, 4 deletions
diff --git a/files/ajax/scan.php b/files/ajax/scan.php
new file mode 100644
index 00000000000..f7e75d5f8ba
--- /dev/null
+++ b/files/ajax/scan.php
@@ -0,0 +1,31 @@
+<?php
+
+require_once '../../lib/base.php';
+
+set_time_limit(0);//scanning can take ages
+
+$force=isset($_GET['force']) and $_GET['force']=='true';
+$checkOnly=isset($_GET['checkonly']) and $_GET['checkonly']=='true';
+
+if(!$checkOnly){
+ $eventSource=new OC_EventSource();
+}
+
+
+//create the file cache if necesary
+if($force or !OC_FileCache::inCache('')){
+ if(!$checkOnly){
+ OC_FileCache::scan('',false,$eventSource);
+ $eventSource->send('success',true);
+ }else{
+ OC_JSON::success(array('data'=>array('done'=>true)));
+ exit;
+ }
+}else{
+ if(isset($eventSource)){
+ $eventSource->send('success',false);
+ }else{
+ exit;
+ }
+}
+$eventSource->close(); \ No newline at end of file
diff --git a/files/ajax/upload.php b/files/ajax/upload.php
index 5f0f68d9531..241edc216ff 100644
--- a/files/ajax/upload.php
+++ b/files/ajax/upload.php
@@ -47,7 +47,7 @@ if(strpos($dir,'..') === false){
$fileCount=count($files['name']);
for($i=0;$i<$fileCount;$i++){
$target=stripslashes($dir) . $files['name'][$i];
- if(OC_Filesystem::fromUploadedFile($files['tmp_name'][$i],$target)){
+ if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i],$target)){
$result[]=array( "status" => "success", 'mime'=>OC_Filesystem::getMimeType($target),'size'=>OC_Filesystem::filesize($target),'name'=>$files['name'][$i]);
}
}
diff --git a/files/css/files.css b/files/css/files.css
index 13ed7fb33e4..512e462cb6f 100644
--- a/files/css/files.css
+++ b/files/css/files.css
@@ -76,4 +76,6 @@ a.action>img{ max-height:16px; max-width:16px; }
/* 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 }
diff --git a/files/js/files.js b/files/js/files.js
index 7c04245c223..bebcf4e97a4 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -336,8 +336,37 @@ $(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
+ scanFiles.scanning=true;
+ $('#scanning-message').show();
+ $('#fileList').remove();
+ var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force});
+ scanFiles.cancel=scannerEventSource.close.bind(scannerEventSource);
+ scannerEventSource.listen('scanning',function(data){
+ $('#scan-count').text(data.count+' files scanned');
+ $('#scan-current').text(data.file+'/');
+ });
+ scannerEventSource.listen('success',function(success){
+ scanFiles.scanning=false;
+ if(success){
+ window.location.reload();
+ }else{
+ alert('error while scanning');
+ }
+ });
+}
+scanFiles.scanning=false;
+
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 38a3274ff31..7e9505dec2f 100644
--- a/files/templates/index.php
+++ b/files/templates/index.php
@@ -57,3 +57,11 @@
<?php echo $l->t('The files you are trying to upload exceed the maximum size for file uploads on this server.');?>
</p>
</div>
+<div id="scanning-message">
+ <h3>
+ <?php echo $l->t('Files are being scanned, please wait.');?> <span id='scan-count'></spann>
+ </h3>
+ <p>
+ <?php echo $l->t('Current scanning');?> <span id='scan-current'></spann>
+ </p>
+</div>
diff --git a/files/templates/part.list.php b/files/templates/part.list.php
index a364862119d..92b6f37d8e7 100644
--- a/files/templates/part.list.php
+++ b/files/templates/part.list.php
@@ -10,8 +10,8 @@
$name = str_replace('%2F','/', $name);
$directory = str_replace('+','%20',urlencode($file['directory']));
$directory = str_replace('%2F','/', $directory); ?>
- <tr data-file="<?php echo $name;?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>' data-write='<?php echo $write;?>'>
- <td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mime']); ?>)">
+ <tr data-file="<?php echo $name;?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mimetype']?>" data-size='<?php echo $file['size'];?>' data-write='<?php echo $write;?>'>
+ <td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mimetype']); ?>)">
<?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" /><?php } ?>
<a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseURL'].$directory.'/'.$name; else echo $_['downloadURL'].$directory.'/'.$name; ?>" title="">
<span class="nametext">