From 294e39836cb55a6dde13e968b23a0ad97e0b08a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Mon, 13 Jul 2015 12:35:39 +0200 Subject: [PATCH] Deleted folder (still in trash) results in errors while accessing parent folder via webdav #404 --- lib/redmine_dmsf/patches/project_patch.rb | 4 ++-- lib/redmine_dmsf/webdav/controller.rb | 4 +++- lib/redmine_dmsf/webdav/dmsf_resource.rb | 8 ++++---- lib/redmine_dmsf/webdav/resource_proxy.rb | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index 086b76e4..08d405e2 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -67,8 +67,8 @@ module RedmineDmsf module InstanceMethods def dmsf_count - file_count = self.dmsf_files.visible.count + self.file_links.count - folder_count = self.dmsf_folders.visible.count + self.folder_links.count + file_count = self.dmsf_files.visible.count + self.file_links.visible.count + folder_count = self.dmsf_folders.visible.count + self.folder_links.visible.count self.dmsf_folders.visible.each do |f| file_count += f.deep_file_count folder_count += f.deep_folder_count diff --git a/lib/redmine_dmsf/webdav/controller.rb b/lib/redmine_dmsf/webdav/controller.rb index a1140166..c8be5f39 100644 --- a/lib/redmine_dmsf/webdav/controller.rb +++ b/lib/redmine_dmsf/webdav/controller.rb @@ -1,7 +1,9 @@ +# encoding: utf-8 +# # Redmine plugin for Document Management System "Features" # # Copyright (C) 2012 Daniel Munn -# Copyright (C) 2011-14 Karel Picman +# Copyright (C) 2011-15 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/lib/redmine_dmsf/webdav/dmsf_resource.rb b/lib/redmine_dmsf/webdav/dmsf_resource.rb index 8a024cf6..e921700b 100644 --- a/lib/redmine_dmsf/webdav/dmsf_resource.rb +++ b/lib/redmine_dmsf/webdav/dmsf_resource.rb @@ -54,7 +54,7 @@ module RedmineDmsf return @children if @children @children = [] return [] unless collection? - folder.subfolders.map do |p| + folder.subfolders.visible.map do |p| @children.push child(p.title) end folder.files.visible.map do |p| @@ -81,13 +81,13 @@ module RedmineDmsf # Todo: Move folder data retrieval into folder function, and use folder method to determine existence def folder return @folder unless @folder == false - return nil if project.nil? || project.id.nil? #if the project doesnt exist, this entity can't exist + return nil if project.nil? || project.id.nil? #if the project doesn't exist, this entity can't exist @folder = nil # Note: Folder is searched for as a generic search to prevent SQL queries being generated: # if we were to look within parent, we'd have to go all the way up the chain as part of the - # existence check, and although I'm sure we'd love to access the heirarchy, I can't yet + # existence check, and although I'm sure we'd love to access the hierarchy, I can't yet # see a practical need for it - folders = DmsfFolder.visible.where(:project_id => project.id, :title => basename).order('title ASC').all + folders = DmsfFolder.visible.where(:project_id => project.id, :title => basename).order('title ASC').to_a return nil unless folders.length > 0 if (folders.length > 1) then folders.delete_if { |x| '/' + x.dmsf_path_str != projectless_path } diff --git a/lib/redmine_dmsf/webdav/resource_proxy.rb b/lib/redmine_dmsf/webdav/resource_proxy.rb index 96df6af7..1742c8a3 100644 --- a/lib/redmine_dmsf/webdav/resource_proxy.rb +++ b/lib/redmine_dmsf/webdav/resource_proxy.rb @@ -1,7 +1,9 @@ +# encoding: utf-8 +# # Redmine plugin for Document Management System "Features" # # Copyright (C) 2012 Daniel Munn -# Copyright (C) 2011-14 Karel Picman +# Copyright (C) 2011-15 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License