|
@@ -1029,6 +1029,28 @@ ReplaceSuperFile(const varstring lsuperfn,const varstring lfn,const varstring by
|
|
|
FinishSuperFileTransaction(boolean rollback=false);
|
|
|
*/
|
|
|
|
|
|
+class CImplicitSuperTransaction
|
|
|
+{
|
|
|
+ IDistributedFileTransaction *transaction;
|
|
|
+public:
|
|
|
+ CImplicitSuperTransaction(IDistributedFileTransaction *_transaction)
|
|
|
+ {
|
|
|
+ if (!_transaction->active()) // then created implicitly
|
|
|
+ {
|
|
|
+ transaction = _transaction;
|
|
|
+ transaction->start();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ transaction = NULL;
|
|
|
+ }
|
|
|
+ ~CImplicitSuperTransaction()
|
|
|
+ {
|
|
|
+ if (transaction)
|
|
|
+ transaction->commit();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
static bool lookupSuperFile(ICodeContext *ctx, const char *lsuperfn, Owned<IDistributedSuperFile> &file, bool throwerr, StringBuffer &lsfn, bool allowforeign, bool cacheFiles=false)
|
|
|
{
|
|
|
lsfn.clear();
|
|
@@ -1121,6 +1143,7 @@ FILESERVICES_API unsigned FILESERVICES_CALL fsGetSuperFileSubCount(ICodeContext
|
|
|
Owned<ISimpleSuperFileEnquiry> enq = getSimpleSuperFileEnquiry(ctx, lsuperfn);
|
|
|
if (enq)
|
|
|
return enq->numSubFiles();
|
|
|
+ CImplicitSuperTransaction implicitTransaction(ctx->querySuperFileTransaction());
|
|
|
Owned<IDistributedSuperFile> file;
|
|
|
StringBuffer lsfn;
|
|
|
lookupSuperFile(ctx, lsuperfn, file, true, lsfn, true);
|
|
@@ -1138,6 +1161,7 @@ FILESERVICES_API char * FILESERVICES_CALL fsGetSuperFileSubName(ICodeContext *c
|
|
|
return CTXSTRDUP(parentCtx, "");
|
|
|
return ret.detach();
|
|
|
}
|
|
|
+ CImplicitSuperTransaction implicitTransaction(ctx->querySuperFileTransaction());
|
|
|
Owned<IDistributedSuperFile> file;
|
|
|
StringBuffer lsfn;
|
|
|
lookupSuperFile(ctx, lsuperfn, file, true, lsfn, true);
|
|
@@ -1156,6 +1180,7 @@ FILESERVICES_API unsigned FILESERVICES_CALL fsFindSuperFileSubName(ICodeContext
|
|
|
unsigned n = enq->findSubName(lfn.str());
|
|
|
return (n==NotFound)?0:n+1;
|
|
|
}
|
|
|
+ CImplicitSuperTransaction implicitTransaction(ctx->querySuperFileTransaction());
|
|
|
Owned<IDistributedSuperFile> file;
|
|
|
StringBuffer lsfn;
|
|
|
lookupSuperFile(ctx, lsuperfn, file, true, lsfn, true);
|
|
@@ -1189,27 +1214,6 @@ FILESERVICES_API void FILESERVICES_CALL fsAddSuperFile(IGlobalCodeContext *gctx,
|
|
|
}
|
|
|
|
|
|
|
|
|
-class CImplicitSuperTransaction
|
|
|
-{
|
|
|
- IDistributedFileTransaction *transaction;
|
|
|
-public:
|
|
|
- CImplicitSuperTransaction(IDistributedFileTransaction *_transaction)
|
|
|
- {
|
|
|
- if (!_transaction->active()) // then created implicitly
|
|
|
- {
|
|
|
- transaction = _transaction;
|
|
|
- transaction->start();
|
|
|
- }
|
|
|
- else
|
|
|
- transaction = NULL;
|
|
|
- }
|
|
|
- ~CImplicitSuperTransaction()
|
|
|
- {
|
|
|
- if (transaction)
|
|
|
- transaction->commit();
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
FILESERVICES_API void FILESERVICES_CALL fslAddSuperFile(ICodeContext *ctx, const char *lsuperfn,const char *_lfn,unsigned atpos,bool addcontents, bool strict)
|
|
|
{
|
|
|
Owned<IDistributedSuperFile> file;
|
|
@@ -1707,6 +1711,7 @@ FILESERVICES_API void FILESERVICES_CALL fsSuperFileContents(ICodeContext *ctx, s
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
+ CImplicitSuperTransaction implicitTransaction(ctx->querySuperFileTransaction());
|
|
|
Owned<IDistributedSuperFile> file;
|
|
|
StringBuffer lsfn;
|
|
|
lookupSuperFile(ctx, lsuperfn, file, true, lsfn, true);
|
|
@@ -2166,12 +2171,18 @@ FILESERVICES_API void FILESERVICES_CALL fsDeleteExternalFile(ICodeContext * ctx
|
|
|
AuditMessage(ctx,"DeleteExternalFile",path);
|
|
|
}
|
|
|
|
|
|
-FILESERVICES_API void FILESERVICES_CALL fsCreateExternalDirectory(ICodeContext * ctx,const char *location,const char *path)
|
|
|
+FILESERVICES_API void FILESERVICES_CALL fsCreateExternalDirectory(ICodeContext * ctx,const char *location,const char *_path)
|
|
|
{
|
|
|
SocketEndpoint ep(location);
|
|
|
if (ep.isNull())
|
|
|
- throw MakeStringException(-1,"fsCreateExternalDirectory: Cannot resolve location %s",location);
|
|
|
+ throw MakeStringException(-1, "fsCreateExternalDirectory: Cannot resolve location %s",location);
|
|
|
CDfsLogicalFileName lfn;
|
|
|
+ StringBuffer path(_path);
|
|
|
+ if (0 == path.length())
|
|
|
+ throw MakeStringException(-1, "fsCreateExternalDirectory: empty directory");
|
|
|
+ // remove trailing path separator if present to make it look like a regular LFN after lfn.setExternal
|
|
|
+ if (isPathSepChar(path.charAt(path.length()-1)))
|
|
|
+ path.remove(path.length()-1, 1);
|
|
|
lfn.setExternal(location,path);
|
|
|
checkExternalFileRights(ctx,lfn,false,true);
|
|
|
RemoteFilename rfn;
|