apache_upload_merger 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +2 -0
- data/README +9 -6
- data/Rakefile +7 -8
- data/lib/apache/upload_merger.rb +46 -24
- data/lib/apache/upload_merger/version.rb +1 -1
- metadata +32 -49
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea995b05557c1680e8ba7cb1cde93aa53450f576
|
4
|
+
data.tar.gz: 07fb98df77c5e5f17fbd2fe3210ba3738ca45aaf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 934b7fa5cb575a44af96a732af7d31e1e2fd2a991559d9c09afc348b449df840f474972f746d380512d1f8b584c395b6f3a208917b63e37a11fd7c683a19bb92
|
7
|
+
data.tar.gz: d7cb11bf89f4f7af812ee9ee47d906028bbcb86a6037c43c30539b3b5f1e06d7a07e3e08dbba707cc587994b765c00126bb36ae2a88b12f850efcbb708ba72e9
|
data/ChangeLog
CHANGED
data/README
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== VERSION
|
4
4
|
|
5
|
-
This documentation refers to apache_upload_merger version 0.0.
|
5
|
+
This documentation refers to apache_upload_merger version 0.0.3
|
6
6
|
|
7
7
|
|
8
8
|
== DESCRIPTION
|
@@ -31,19 +31,22 @@ Place the following snippet in your Apache config:
|
|
31
31
|
== LINKS
|
32
32
|
|
33
33
|
<b></b>
|
34
|
-
Documentation::
|
35
|
-
Source code::
|
34
|
+
Documentation:: http://blackwinter.github.com/apache_upload_merger
|
35
|
+
Source code:: http://github.com/blackwinter/apache_upload_merger
|
36
|
+
RubyGem:: http://rubygems.org/gems/apache_upload_merger
|
36
37
|
|
37
38
|
|
38
39
|
== AUTHORS
|
39
40
|
|
40
|
-
* Jens Wille <mailto:jens.wille@
|
41
|
+
* Jens Wille <mailto:jens.wille@gmail.com>
|
41
42
|
|
42
43
|
|
43
44
|
== LICENSE AND COPYRIGHT
|
44
45
|
|
45
|
-
Copyright (C) 2010 University of Cologne,
|
46
|
-
Albertus-Magnus-Platz,
|
46
|
+
Copyright (C) 2010-2012 University of Cologne,
|
47
|
+
Albertus-Magnus-Platz, 50923 Cologne, Germany
|
48
|
+
|
49
|
+
Copyright (C) 2013 Jens Wille
|
47
50
|
|
48
51
|
apache_upload_merger is free software: you can redistribute it and/or modify it under
|
49
52
|
the terms of the GNU General Public License as published by the Free Software
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require %q{lib/apache/upload_merger/version}
|
1
|
+
require File.expand_path(%q{../lib/apache/upload_merger/version}, __FILE__)
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'hen'
|
@@ -8,14 +8,13 @@ begin
|
|
8
8
|
:name => %q{apache_upload_merger},
|
9
9
|
:version => Apache::UploadMerger::VERSION,
|
10
10
|
:summary => %q{Apache module providing upload merging functionality.},
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
11
|
+
:author => %q{Jens Wille},
|
12
|
+
:email => %q{jens.wille@gmail.com},
|
13
|
+
:license => %q{AGPL-3.0},
|
14
|
+
:homepage => :blackwinter,
|
14
15
|
:dependencies => %w[]
|
15
16
|
}
|
16
17
|
}}
|
17
|
-
rescue LoadError
|
18
|
-
abort "Please install the
|
18
|
+
rescue LoadError => err
|
19
|
+
abort "Please install the `hen' gem first. (#{err})"
|
19
20
|
end
|
20
|
-
|
21
|
-
### Place your custom Rake tasks here.
|
data/lib/apache/upload_merger.rb
CHANGED
@@ -4,12 +4,14 @@
|
|
4
4
|
# apache_upload_merger -- Apache module providing upload merging #
|
5
5
|
# functionality #
|
6
6
|
# #
|
7
|
-
# Copyright (C) 2010 University of Cologne,
|
8
|
-
#
|
9
|
-
#
|
7
|
+
# Copyright (C) 2010-2012 University of Cologne, #
|
8
|
+
# Albertus-Magnus-Platz, #
|
9
|
+
# 50923 Cologne, Germany #
|
10
|
+
# #
|
11
|
+
# Copyright (C) 2013 Jens Wille #
|
10
12
|
# #
|
11
13
|
# Authors: #
|
12
|
-
# Jens Wille <jens.wille@
|
14
|
+
# Jens Wille <jens.wille@gmail.com> #
|
13
15
|
# #
|
14
16
|
# apache_upload_merger is free software: you can redistribute it and/or #
|
15
17
|
# modify it under the terms of the GNU General Public License as published by #
|
@@ -34,17 +36,26 @@ module Apache
|
|
34
36
|
|
35
37
|
class UploadMerger
|
36
38
|
|
37
|
-
|
39
|
+
DEFAULT_MERGE_THRESHOLD = 32 * 1024 * 1024
|
38
40
|
|
39
|
-
|
41
|
+
CREATE_MODE = Fcntl::O_CREAT|Fcntl::O_WRONLY|Fcntl::O_EXCL
|
40
42
|
|
41
43
|
# Creates a new RubyHandler instance for the Apache web server. It
|
42
44
|
# is to be installed as a custom 404 ErrorDocument handler.
|
43
45
|
#
|
44
46
|
# The argument +map+ contains key/value pairs of URL prefixes and
|
45
47
|
# upload base directories.
|
46
|
-
|
47
|
-
|
48
|
+
#
|
49
|
+
# +strategy+ determines how merging happens:
|
50
|
+
#
|
51
|
+
# <tt>:symlink</tt>:: Files are symlinked
|
52
|
+
# <tt>:copy</tt>:: Files are copied
|
53
|
+
# <tt>Integer</tt>:: Files whose size is below that threshold are
|
54
|
+
# copied, others are symlinked (default)
|
55
|
+
def initialize(map = {}, strategy = DEFAULT_MERGE_THRESHOLD)
|
56
|
+
@map, @strategy = {}, strategy
|
57
|
+
|
58
|
+
define_merger
|
48
59
|
|
49
60
|
map.each { |prefix, dir|
|
50
61
|
@map[prefix] = [%r{\A#{prefix}/(.*)}, dir]
|
@@ -52,20 +63,19 @@ module Apache
|
|
52
63
|
end
|
53
64
|
|
54
65
|
# If the current +request+ asked for a resource that's not there,
|
55
|
-
# it will be
|
56
|
-
# determined by its URL prefix.
|
57
|
-
# be thrown.
|
66
|
+
# it will be merged from one of the appropriate upload directories,
|
67
|
+
# determined by its URL prefix. If no matching resource could be
|
68
|
+
# found, the original error will be thrown.
|
58
69
|
def handler(request)
|
59
70
|
request.add_common_vars # REDIRECT_URL
|
60
71
|
|
61
72
|
if url = request.subprocess_env['REDIRECT_URL'] and
|
62
|
-
prefix = request.path_info
|
73
|
+
prefix = request.path_info.untaint and
|
63
74
|
map = @map[prefix] and
|
64
75
|
path = url[map[0], 1].untaint and
|
65
76
|
src = find(map[1], path)
|
66
77
|
|
67
|
-
merge(src,
|
68
|
-
File.join(request.server.document_root, prefix, path).untaint)
|
78
|
+
merge(src, File.join(request.server.document_root, prefix, path))
|
69
79
|
|
70
80
|
request.status = HTTP_OK
|
71
81
|
request.internal_redirect(url)
|
@@ -86,19 +96,31 @@ module Apache
|
|
86
96
|
}
|
87
97
|
end
|
88
98
|
|
89
|
-
|
90
|
-
|
99
|
+
def define_merger
|
100
|
+
class << self; self; end.send :alias_method, :merge, case @strategy
|
101
|
+
when :symlink, :copy then @strategy
|
102
|
+
when Integer then :copy_or_symlink
|
103
|
+
else raise ArgumentError, "illegal strategy #{@strategy.inspect}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def copy_or_symlink(src, dest)
|
91
108
|
stat = File.stat(src)
|
109
|
+
stat.size > @strategy ? symlink(src, dest) : copy(src, dest, stat)
|
110
|
+
end
|
92
111
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
112
|
+
def symlink(src, dest)
|
113
|
+
File.symlink(src, dest)
|
114
|
+
rescue Errno::EEXIST
|
115
|
+
end
|
116
|
+
|
117
|
+
# TODO: optimize?
|
118
|
+
def copy(src, dest, stat = File.stat(src))
|
119
|
+
File.open(src) { |src_|
|
120
|
+
File.open(dest, CREATE_MODE, stat.mode) { |dest_|
|
121
|
+
FileUtils.copy_stream(src_, dest_)
|
100
122
|
}
|
101
|
-
|
123
|
+
}
|
102
124
|
rescue Errno::EEXIST
|
103
125
|
end
|
104
126
|
|
metadata
CHANGED
@@ -1,77 +1,60 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: apache_upload_merger
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Jens Wille
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2010-02-26 00:00:00 +01:00
|
18
|
-
default_executable:
|
11
|
+
date: 2013-12-19 00:00:00.000000000 Z
|
19
12
|
dependencies: []
|
20
|
-
|
21
13
|
description: Apache module providing upload merging functionality.
|
22
|
-
email: jens.wille@
|
14
|
+
email: jens.wille@gmail.com
|
23
15
|
executables: []
|
24
|
-
|
25
16
|
extensions: []
|
26
|
-
|
27
|
-
|
17
|
+
extra_rdoc_files:
|
18
|
+
- README
|
28
19
|
- COPYING
|
29
20
|
- ChangeLog
|
30
|
-
|
31
|
-
files:
|
21
|
+
files:
|
32
22
|
- lib/apache/upload_merger.rb
|
33
23
|
- lib/apache/upload_merger/version.rb
|
34
|
-
-
|
24
|
+
- COPYING
|
35
25
|
- ChangeLog
|
26
|
+
- README
|
36
27
|
- Rakefile
|
37
|
-
- COPYING
|
38
|
-
has_rdoc: true
|
39
28
|
homepage: http://github.com/blackwinter/apache_upload_merger
|
40
|
-
licenses:
|
41
|
-
|
29
|
+
licenses:
|
30
|
+
- AGPL-3.0
|
31
|
+
metadata: {}
|
42
32
|
post_install_message:
|
43
|
-
rdoc_options:
|
44
|
-
- --
|
33
|
+
rdoc_options:
|
34
|
+
- "--title"
|
35
|
+
- apache_upload_merger Application documentation (v0.0.3)
|
36
|
+
- "--charset"
|
45
37
|
- UTF-8
|
46
|
-
- --
|
47
|
-
-
|
48
|
-
- --main
|
38
|
+
- "--line-numbers"
|
39
|
+
- "--all"
|
40
|
+
- "--main"
|
49
41
|
- README
|
50
|
-
|
51
|
-
- --inline-source
|
52
|
-
- --all
|
53
|
-
require_paths:
|
42
|
+
require_paths:
|
54
43
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
57
46
|
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
64
51
|
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
- 0
|
68
|
-
version: "0"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
69
54
|
requirements: []
|
70
|
-
|
71
55
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.
|
56
|
+
rubygems_version: 2.1.11
|
73
57
|
signing_key:
|
74
|
-
specification_version:
|
58
|
+
specification_version: 4
|
75
59
|
summary: Apache module providing upload merging functionality.
|
76
60
|
test_files: []
|
77
|
-
|