     @api.get FILES, criteria, (result) =>
       this.fileNode row for row in result.rows
 
+  findFile: (name) ->
+    @api.get FILES, name: name, (result) =>
+      this.fileNode result
+
+  updateFileNode: (file) ->
+    node = $ "#files li[data-id='#{file.id}']"
+    size = this.size file.size
+    time = this.date file.created_at
+    node.data 'file', file
+    $('h2', node).text file.name
+    $('.size', node).text size
+    $('.time', node).text time
+    node.attr 'data-name', file.name
+    node.attr 'data-size', size
+    node.attr 'data-created', time
+
   fileNode: (file) ->
-    size = this.size file.size
-    if !file.created_at
-      file.created_at = Date()
-    time = this.date file.created_at
+    if $("#files li[data-id='#{file.id}']").length > 0
+      this.updateFileNode file
+      return
+
     node = $("""
-      <li data-id="#{file.id}" data-name="" data-size="#{size}" data-created="#{time}">
+      <li data-id="#{file.id}">
         <div class="file-icon">
-          <span class="size">#{size}</span>
+          <span class="size"></span>
         </div>
         <h2></h2>
         <footer>
-          <span class="time">#{time}</span>
+          <span class="time"></span>
           <ul class="labels"></ul>
           <form class="add-label">
             <div class="add-label-button"></div>

    $('.add-label-button', node).click ->
      $('form.add-label input[type="text"]', node).show()

    this.labelNode node, label for label in file.labels

  labelNode: (node, label) ->
    labels = $('.labels', node)

      jid: @api.jid
      size: this.size
      complete: (file) =>
        this.findFile file.name

  findLabels: ->
    $('#labels').empty()
