redmine_scm_extensions
redmine_scm_extensions copied to clipboard
Unable to delete files in filesystem repository
I installed the plugin (0.1.0) and then created a filesystem repository. Then I created some folders there, and uploaded files. Then I tried to delete a single file in these folders. Therefore I opened it in redmine and klicked on 'Delete File'. But instead of deleting the file I got an error message:
Internal error An error occurred on the page you were trying to access. If you continue to experience problems please contact your redMine administrator for assistance. Back
On unix-side the files were created as user 'root' group 'root', permissions 644 / 755. So first I modified the permissions to rwxrwsrwx for all folders and files. Anyway: It' not possible to remove a single file. Removing a folder works find, also if there were some files inside. Regards Dieter
Dieter, Have you got more information in the log file (redmine/log/production.log) because I can't reproduce your error... I created a directory (/opt/appli/temp-day) as root:root, then chmod 777 /opt/appli/temp-day and I didn't have any issue when uploading a file then deleting it...
For information: I successfully use the plugin everyday with several filesystem repositories but I agree that I have special settings. Here are my commands to create a new repo: #mkdir /repositories/test #mkdir /repositories/test/files #mkdir /repositories/test/attributes #chown -R apache:apache /repositories/test
Then, in Redmine (project's settings): SCM->filsystem Root directory-> /repositories/test/files
Kind regards, Arnaud
Amaud now I also tried to create the attribute directory (in same directory as root of repository). User apache and group apache don't exist in my OS, but all directories and files have full read/write permissions for all (rwxrwxrwx). Anyway, I cann't delete a file. Also I cannot see any comments or descriptions keyed in while uploading a file.. Do I have to enable or configure subversion although I don't use it..?
One more hint: The users list to be reached on bottom of repository settings is empty. My redmine user doesn't exist on OS. So no user is mapped (how to do this? There is no button for). Dieter Egert
Dieter, I think I found where is the problem. I have patched a file in redmine (redmine/lib/redmine/scm/adapters/filesystem_adapter.rb) and that's why you can't delete file (and why you don't see author names). Regarding the comments, it was too complicated to store them so they are justed used for notifications. I'm really sorry but I completely forgot this patch.. As I can't attach a file to my reply, here is the content of this file. Could you tell me if it solves everything??
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# FileSystem adapter
# File written by Paul Rivier, at Demotera.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'redmine/scm/adapters/abstract_adapter'
require 'find'
module Redmine
module Scm
module Adapters
class FilesystemAdapter target(),
:lastrev => nil
})
info
rescue CommandFailed
return nil
end
def entries(path="", identifier=nil)
metapath=self.url =~ /^\/repositories\/[^\/]*\/files\//
entries = Entries.new
return entries if (File.exist?(target(path)) && !File.directory?(target(path)))
Dir.new(target(path)).each do |e|
relative_path = format_path_ends((format_path_ends(path,
false,
true) + e),
false,false)
target = target(relative_path)
author=""
if metapath
metapathtarget = target.sub(/\/files\//, "/attributes/")
if File.exist?(metapathtarget) && !File.directory?(metapathtarget)
File.open(metapathtarget, "r") do |f|
author = f.gets
end
end
end
entries File.basename(e),
# below : list unreadable files, but dont link them.
:path => File.readable?(target) ? relative_path : "",
:kind => (File.directory?(target) ? 'dir' : 'file'),
:size => (File.directory?(target) ? nil : [File.size(target)].pack('l').unpack('L').first),
:lastrev =>
Revision.new({:time => (File.mtime(target)).localtime,
:author => author
})
}) if File.exist?(target) and # paranoid test
%w{file directory}.include?(File.ftype(target)) and # avoid special types
not File.basename(e).match(/^\.+$/) # avoid . and ..
end
entries.sort_by_name
end
def cat(path, identifier=nil)
File.new(target(path), "rb").read
end
private
# AbstractAdapter::target is implicitly made to quote paths.
# Here we do not shell-out, so we do not want quotes.
def target(path=nil)
#Prevent the use of ..
if path and !path.match(/(^|\/)\.\.(\/|$)/)
return "#{self.url}#{without_leading_slash(path)}"
end
return self.url
end
end
end
end
end
Hi I replaced the existing file on the path you mentioned by a new file with content in your mail. Then I restarted redmine. Now I can upload and delete any file in the files repository. But: I cannot delete directories, also if they are empty. This was the case in already before I replaced your file. Sometimes I could deleted folders, then I can no longer delete folders. The replacing of the filesystem_adapters.rb didn't improve this.
Also some further suggestions:
- Please replace the text 'Folder/Directory' by just 'Directory' - it looks much better just to use 1 word.
- Comments and file description (properties) is not listed, folder 'attributes' is always empty
- I'm missing the commands 'rename' and 'move' of directories and files
Thanks in advance, I like your plugin really it's great for distribution of cad data! (I'm using redmine for development projects in automotive industry.. great!) Dieter Egert
Dieter Egert, Fon 07151-507647 DEST Ingenieurbüro, Waiblingen www.dest.de
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the interested recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
2011/4/6 amartel [email protected]:
Dieter, I think I found where is the problem. I have patched a file in redmine (redmine/lib/redmine/scm/adapters/filesystem_adapter.rb) and that's why you can't delete file (and why you don't see author names). Regarding the comments, it was too complicated to store them so they are justed used for notifications. I'm really sorry but I completely forgot this patch.. As I can't attach a file to my reply, here is the content of this file. Could you tell me if it solves everything??
# redMine - project management software # Copyright (C) 2006-2007 Jean-Philippe Lang # # FileSystem adapter # File written by Paul Rivier, at Demotera. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require 'redmine/scm/adapters/abstract_adapter' require 'find' module Redmine module Scm module Adapters class FilesystemAdapter target(), :lastrev => nil }) info rescue CommandFailed return nil end def entries(path="", identifier=nil) metapath=self.url =~ /^\/repositories\/[^\/]*\/files\// entries = Entries.new return entries if (File.exist?(target(path)) && !File.directory?(target(path))) Dir.new(target(path)).each do |e| relative_path = format_path_ends((format_path_ends(path, false, true) + e), false,false) target = target(relative_path) author="" if metapath metapathtarget = target.sub(/\/files\//, "/attributes/") if File.exist?(metapathtarget) && !File.directory?(metapathtarget) File.open(metapathtarget, "r") do |f| author = f.gets end end end entries File.basename(e), # below : list unreadable files, but dont link them. :path => File.readable?(target) ? relative_path : "", :kind => (File.directory?(target) ? 'dir' : 'file'), :size => (File.directory?(target) ? nil : [File.size(target)].pack('l').unpack('L').first), :lastrev => Revision.new({:time => (File.mtime(target)).localtime, :author => author }) }) if File.exist?(target) and # paranoid test %w{file directory}.include?(File.ftype(target)) and # avoid special types not File.basename(e).match(/^\.+$/) # avoid . and .. end entries.sort_by_name end def cat(path, identifier=nil) File.new(target(path), "rb").read end private # AbstractAdapter::target is implicitly made to quote paths. # Here we do not shell-out, so we do not want quotes. def target(path=nil) #Prevent the use of .. if path and !path.match(/(^|\/)\.\.(\/|$)/) return "#{self.url}#{without_leading_slash(path)}" end return self.url end end end end endReply to this email directly or view it on GitHub: https://github.com/amartel/redmine_scm_extensions/issues/3#comment_964621
Hi here the production.log when trying to delete a (sub)directory:
Logfile created on Thu Apr 07 14:08:59 +0000 2011
Processing RepositoriesController#show (for 79.210.70.206 at 2011-04-07 14:09:06) [GET] Parameters: {"action"=>"show", "id"=>"dest-internal", "path"=>[], "controller"=>"repositories"} Rendering template within layouts/base Rendering repositories/show Completed in 403ms (View: 311, DB: 53) | 200 OK [http://project.dest.de/redmine/projects/dest-internal/repository/show]
Processing RepositoriesController#show (for 79.210.70.206 at 2011-04-07 14:09:08) [GET] Parameters: {"action"=>"show", "id"=>"dest-internal", "path"=>["aim-na-v7"], "controller"=>"repositories"} Rendering template within layouts/base Rendering repositories/show Completed in 46ms (View: 33, DB: 3) | 200 OK [http://project.dest.de/redmine/projects/dest-internal/repository/show/aim-na-v7]
Processing RepositoriesController#show (for 79.210.70.206 at 2011-04-07 14:09:09) [GET] Parameters: {"action"=>"show", "id"=>"dest-internal", "path"=>["aim-na-v7", "from_dest"], "controller"=>"repositories"} Rendering template within layouts/base Rendering repositories/show Completed in 44ms (View: 31, DB: 3) | 200 OK [http://project.dest.de/redmine/projects/dest-internal/repository/show/aim-na-v7/from_dest]
Processing RepositoriesController#show (for 79.210.70.206 at 2011-04-07 14:09:10) [GET] Parameters: {"action"=>"show", "id"=>"dest-internal", "path"=>["aim-na-v7", "from_dest", "gsdf"], "controller"=>"repositories"} Rendering template within layouts/base Rendering repositories/show Completed in 43ms (View: 30, DB: 3) | 200 OK [http://project.dest.de/redmine/projects/dest-internal/repository/show/aim-na-v7/from_dest/gsdf]
Processing ScmExtensionsController#delete (for 79.210.70.206 at 2011-04-07 14:09:12) [GET] Parameters: {"action"=>"delete", "id"=>"dest-internal", "path"=>"aim-na-v7/from_dest/gsdf", "controller"=>"scm_extensions"} Redirected to http://project.dest.de/redmine/projects/dest-internal/repository/show/aim-na-v7/from_dest/gsdf Completed in 14ms (DB: 1) | 302 Found [http://project.dest.de/redmine/scm_extensions/delete/dest-internal?path=aim-na-v7%2Ffrom_dest%2Fgsdf]
Processing RepositoriesController#show (for 79.210.70.206 at 2011-04-07 14:09:12) [GET] Parameters: {"action"=>"show", "id"=>"dest-internal", "path"=>["aim-na-v7", "from_dest", "gsdf"], "controller"=>"repositories"} Rendering template within layouts/base Rendering repositories/show Completed in 185ms (View: 147, DB: 7) | 200 OK [http://project.dest.de/redmine/projects/dest-internal/repository/show/aim-na-v7/from_dest/gsdf]
Processing RepositoriesController#show (for 79.210.70.206 at 2011-04-07 14:09:15) [GET] Parameters: {"action"=>"show", "id"=>"dest-internal", "path"=>[], "controller"=>"repositories"} Rendering template within layouts/base Rendering repositories/show Completed in 53ms (View: 39, DB: 3) | 200 OK [http://project.dest.de/redmine/projects/dest-internal/repository/show]
Hi and a last remark /hint: The directory 'attributes' now is not empty after sucessfully deleting the file. Instead now there is a subfolder-tree created inside 'attributes' with same path as the deleted file, and instead of the deleted file here is a new file 'production.log'. It's content is just the name of the redmine user who deleted the file.
Regards Dieter
Amartel
now I installed redmine 1.3.0.stable (bitnami stack) on an new virtual machine. Also I installed your pluginredmine_scm_extensions with the command as you recommended: ruby script/plugin install http://github.com/amartel/redmine_scm_extensions.git Furthermore I performed rake db:migrate_plugins RAILS_ENV=production ctlscript.sh restart
Although it is impossible in a filesystem scm to remove any file or folder, no matter if the folder is empty or not. I get this error message in the browser (deleting or uploading a file), white page with this text:
Internal error An error occurred on the page you were trying to access. If you continue to experience problems please contact your Redmine administrator for assistance. If you are the Redmine administrator, check your log files for details about the error.
This error message is displayed on a redmine page when trying to delete a folder:
Error. Delete canceled (in a red frame)
May I send the log files as attachment to you? Also I'd give you access to a ssh login user (temporary password) as there are not yet secret data on the server. But to send you the login I need your direct mailadress. My mailadress you'll find on my redmine site: http://dest.de/redmine (see contact).
Regards Dieter
Dieter,
I sent you directly an email. Let me know if I can help...
Kind regards, Arnaud