Skip to content

Commit

Permalink
ftp: add place-holder file size work-around for Globus directory listing
Browse files Browse the repository at this point in the history
Motivation:

For files being currently uploaded we don't yet know the file's size.
As a result, the namespace declines to provide the file's size in the
FileAttributes object.

When making a directory listing with the MLSC command, Globus requires
files have a defined size.  It treats any lack of a SIZE fact as an
error.

Modification:

This patch adds a work-around where incomplete files (those still being
uploaded) have zero length, as a place-holder value.

Result:

Globus transfer service can now list directories that contain incomplete
files, those that are still being uploaded.

Target: master
Request: 7.0
Request: 6.2
Request: 6.1
Request: 6.0
Request: 5.2
Requires-notes: yes
Requires-book: no
Patch: https://rb.dcache.org/r/12768/
Acked-by: Tigran Mkrtchyan
  • Loading branch information
paulmillar authored and mksahakyan committed Jan 27, 2021
1 parent 05cb1a9 commit ffd5090
Showing 1 changed file with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,18 @@ private enum WorkAround
* close our end of the TCP connection once any pending transfers have
* completed.
*/
NO_REPLY_ON_QUIT
NO_REPLY_ON_QUIT,

/**
* Some clients (e.g., Globus) require that files returned during
* directory listing have a definite size. When dCache is accepting a
* new file, the namespace does not know the final file's size so no
* file size is returned to the door. Normally, dCache simply omits the
* file size information when building the response; however, this
* work-around results in such incomplete files being reported as having
* zero length.
*/
USE_PLACEHOLDER_SIZE_FOR_INCOMPLETE_FILES,
}


Expand Down Expand Up @@ -3185,6 +3196,21 @@ public void doClientinfo(String description)
case "globus-url-copy":
_activeWorkarounds.add(WorkAround.NO_REPLY_ON_QUIT);
break;

// Globus (Online) agent for:
// Providing web-portal with directory listing,
// Deleting contents.
// Observed commands: MLST, MLSC, DELE, RMD
case "globusonline-dirlist":
_activeWorkarounds.add(WorkAround.USE_PLACEHOLDER_SIZE_FOR_INCOMPLETE_FILES);
break;

// Globus (Online) agent that seems to do a recursive directory listing
// in preparation of data transfer.
// Observed commands: MLSC, MLST
case "gshtest":
_activeWorkarounds.add(WorkAround.USE_PLACEHOLDER_SIZE_FOR_INCOMPLETE_FILES);
break;
}
reply("250 OK");
}
Expand Down Expand Up @@ -4853,17 +4879,30 @@ public Set<FileAttribute> getRequiredAttributes()
break;
}
}

if (_activeWorkarounds.contains(WorkAround.USE_PLACEHOLDER_SIZE_FOR_INCOMPLETE_FILES)
&& _currentFacts.contains(Fact.SIZE)) {
attributes.add(SIMPLE_TYPE);
}

return attributes;
}

@Override
public void print(FsPath dir, FileAttributes dirAttr, DirectoryEntry entry)
{
FileAttributes attr = entry.getFileAttributes();

if (_activeWorkarounds.contains(WorkAround.USE_PLACEHOLDER_SIZE_FOR_INCOMPLETE_FILES)
&& attr.isDefined(TYPE) && attr.getFileType() == FileType.REGULAR
&& attr.isUndefined(SIZE)) {
attr.setSize(0L);
}

FsPath path = (dir == null) ? FsPath.ROOT : dir.child(entry.getName());

if (!_currentFacts.isEmpty()) {
AccessType access;
FileAttributes attr = entry.getFileAttributes();

for (Fact fact: _currentFacts) {
switch (fact) {
Expand Down

0 comments on commit ffd5090

Please sign in to comment.