Commit 1e95a347 by murtaugh

renaming folders bug fix

1 parent 4516b6d2
......@@ -39,9 +39,9 @@ td.filecontrols.active {
{% endif %}
{% for item in items %}
{% if item.is_dir %}
<tr class="{{item.classes}}"><td class="filecontrols" valign="top"><img src="/__makeserver__/icons/directory.symbolic.png" alt="[DIR]"></td><td><a href="{{item.link}}">{{item.label}}</a>{{item.buttons}}</td><td align="right">{% if item.lasmod %}{{item.lastmod | strftime("%Y-%m-%d %H:%M")}}{%else%}&mdash;{%endif%}</td><td align="right"> - </td><td>&nbsp;</td></tr>
<tr class="{{item.classes}}"><td class="filecontrols" valign="top"><a class="filecontrols" href="{{item.link}}"><img src="/__makeserver__/icons/directory.symbolic.png" alt="[DIR]"></a></td><td class="filename"><a href="{{item.link}}">{{item.label}}</a></td><td align="right">{% if item.lasmod %}{{item.lastmod | strftime("%Y-%m-%d %H:%M")}}{%else%}&mdash;{%endif%}</td><td align="right"> - </td><td>&nbsp;</td></tr>
{% else %}
<tr class="{{item.classes}}"><td class="filecontrols" valign="top"><a class="filecontrols" href="{{item.link}}?edit"><img src="/__makeserver__/icons/{% if item.is_text %}text{%else%}generic{%endif%}.symbolic.png" alt="[ ]" border="0"></a></td><td class="filename"><a href="{{item.link}}{% if item.is_text and not (item.ext == "html" or item.ext == "svg")%}?edit{% endif %}">{{item.label}}</a>{{item.buttons}}</td><td align="right">{% if item.lastmod %}{{item.lastmod | strftime("%Y-%m-%d %H:%M")}}{%else%}&mdash;{%endif%} </td><td align="right">{{item.size|humanize_bytes}}</td><td>&nbsp;</td></tr>
<tr class="{{item.classes}}"><td class="filecontrols" valign="top"><a class="filecontrols" href="{{item.link}}?edit"><img src="/__makeserver__/icons/{% if item.is_text %}text{%else%}generic{%endif%}.symbolic.png" alt="[ ]" border="0"></a></td><td class="filename"><a href="{{item.link}}{% if item.is_text and not (item.ext == "html" or item.ext == "svg")%}?edit{% endif %}">{{item.label}}</a></td><td align="right">{% if item.lastmod %}{{item.lastmod | strftime("%Y-%m-%d %H:%M")}}{%else%}&mdash;{%endif%} </td><td align="right">{{item.size|humanize_bytes}}</td><td>&nbsp;</td></tr>
{% endif %}
{% endfor %}
</table>
......@@ -169,6 +169,7 @@ fc.querySelector("#renamefile").addEventListener("click", function () {
td2 = td.parentNode.querySelector("td.filename");
td2a = td2.querySelector("a");
originalPath = td2a.textContent;
console.log("rename", td, td2, td2a, originalPath);
t = document.createElement("input");
td2a.style.display = "none";
t.value = originalPath;
......
......@@ -121,7 +121,7 @@ class FileSaver (Resource):
self.docroot = docroot
def render_POST(self, request):
# print ("FileSaver.POST", self.path, request)
print ("FileSaver.POST", self.path, request)
data = request.content.read()
data = parse_qs(data)
# print ("data", data)
......@@ -131,12 +131,12 @@ class FileSaver (Resource):
os.utime(self.path, None)
elif "rename" in data:
if "to" in data:
base = os.path.split(self.path)[0]
base = os.path.split(self.path.rstrip('/'))[0]
newpath = os.path.abspath(os.path.join(base, data['to'][0]))
if self.docroot and not newpath.startswith(self.docroot):
print (u"BAD Rename attempt '{0}' to '{1}'".format(self.path, newpath).encode("utf-8"))
return "BAD PATH"
# print (u"Renaming '{0}' to '{1}'".format(self.path, newpath).encode("utf-8"))
print (u"Renaming '{0}' to '{1}'".format(self.path, newpath).encode("utf-8"))
os.rename(self.path, newpath)
elif "text" in data:
text = data['text'][0]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!